Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\lfloor and \rfloor can't be used as function names: invalid character #32077

Closed
utensil opened this issue May 19, 2019 · 6 comments
Closed

\lfloor and \rfloor can't be used as function names: invalid character #32077

utensil opened this issue May 19, 2019 · 6 comments
Labels
parser Language parsing and surface syntax

Comments

@utensil
Copy link

utensil commented May 19, 2019

U+0230A = ⌊ = \lfloor = left floor
U+0230B = ⌋ = \rfloor = right floor

Currently these two unicode characters can't be used as function names, and they are the symbols used in Geometric Algebra for right contraction and left contraction, respectively, so it's natural to wish to use them as operators.

Actually they have been brought up in #8044 (comment) , suggesting that there're ~300 unicode-math symbols that are not currently valid Julia identifiers or operators.

I wonder if it's ok to create a PR to add them to Julia or are there any particular considerations to avoid adding them to Julia? Or just these two?

@JeffBezanson
Copy link
Member

We initially make symbols like this invalid to keep our options open in the future. This is an interesting case since I would have thought ⌊x⌋ would need to mean floor(x), so a good example of why we can't be hasty in deciding how to parse these. But, I worry that if we do parse them, most people will expect them to mean "floor".

@JeffBezanson JeffBezanson added the parser Language parsing and surface syntax label May 19, 2019
@utensil
Copy link
Author

utensil commented May 20, 2019

Thanks for the prompt reply.

These two symbols and their corresponding LaTeX are familiar to anyone who wish to use them in these semantics because they are already in the field. So no further confusion would be caused.

Here's some background of left contraction and right contraction:

image

Source: Geometric algebra - Wikipedia: Extensions of the inner and exterior products

P.S. In most Geometric Algebra libraries, <</>> or </> are used as operators because they are available in many programming languages. So being able to use \lfloor and \rfloor in Julia is something nice to have (i.e. not a necessity). Just wondering if it's possible.

@StefanKarpinski
Copy link
Member

StefanKarpinski commented May 20, 2019

These two symbols and their corresponding LaTeX are familiar to anyone who wish to use them in these semantics because they are already in the field. So no further confusion would be caused.

The problem is that the way they would be parsed for the use as a floor operator is as a balanced bracket pair, whereas you are asking for them to be allowed as standalone infix operators. Those two ways of parsing these characters are quite incompatible, so we'd have to make a choice. The notation of ⌊x⌋ meaning floor is very standard, so it's a bit hard to imagine that we'd do anything else.

Humans are quire good at disambiguating these kinds of things but parsers don't work like that, unfortunately. LaTeX doesn't have to commit to one or the other parsing because it's just a character and it doesn't care about parsing or meaning.

@utensil
Copy link
Author

utensil commented May 21, 2019

The problem is that the way they would be parsed for the use as a floor operator is as a balanced bracket pair, whereas you are asking for them to be allowed as standalone infix operators. Those two ways of parsing these characters are quite incompatible, so we'd have to make a choice. T

I see. So you wish to reserve them for the syntax of ⌊x⌋, instead of being used as general Julia identifiers or operators. I'll close this issue then.

The notation of ⌊x⌋ meaning floor is very standard, so it's a bit hard to imagine that we'd do anything else.

What's standard is relative. For someone in the field of Geometric Algebra, ⌋ for left contraction and ⌊ for right contraction are ubiquitous. Their non-symmetric semantics require visual direction, so it's natural to reuse notations that were used in a balanced bracket pair. This unfortunate ambiguity for parsers is one of the consequences.

@utensil utensil closed this as completed May 21, 2019
@utensil
Copy link
Author

utensil commented May 24, 2019

Just as a note, finally I chose \intprod and \intprodr for contractions, they are supported by Julia and they mean left and right interior product in exterior algebra.

@utensil
Copy link
Author

utensil commented May 28, 2019

Related to #27697 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

3 participants