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

parse \mapsfrom and rest of unicode arrows as infix operators #23224

Closed
stevengj opened this issue Aug 12, 2017 · 8 comments
Closed

parse \mapsfrom and rest of unicode arrows as infix operators #23224

stevengj opened this issue Aug 12, 2017 · 8 comments
Assignees
Labels
parser Language parsing and surface syntax unicode Related to unicode characters and encodings
Milestone

Comments

@stevengj
Copy link
Member

Mentioned in #11223: \mapsfrom (U+21A4) is not currently parsed as an infix operator. It should be parsed with the same precedence as \mapsto ().

@stevengj stevengj added parser Language parsing and surface syntax unicode Related to unicode characters and encodings labels Aug 12, 2017
@stevengj stevengj added this to the 1.0 milestone Aug 12, 2017
@StefanKarpinski
Copy link
Member

This doesn't really belong on the 1.0 milestone since fixing this will not break any code. Of course it would be nice to have, and if someone implements it, great, but it's not a release blocker.

@StefanKarpinski StefanKarpinski modified the milestones: 1.x, 1.0 Aug 12, 2017
@stevengj
Copy link
Member Author

Currently it is parsed as an identifier for some reason, so this would be a breaking change:

julia> ↤ = 7
7

julia> ↤ + 2
9

@stevengj
Copy link
Member Author

stevengj commented Aug 13, 2017

The reason it is an identifier is that \mapsfrom = U+21A4 is in category So (Symbol, Other), not category Sm (Symbol, Math), unlike \mapsto = U+21A6, and everything in So is allowed as an identifier by default.

@stevengj
Copy link
Member Author

stevengj commented Aug 13, 2017

However, many of the things in the Arrows block are parsed as operators, so U+21A4 must have been an oversight. We should go through and make sure that everything in this block is included.

@stevengj stevengj changed the title parse \mapsfrom as an infix operator parse \mapsfrom and rest of arrows block as infix operators Aug 13, 2017
@stevengj stevengj modified the milestones: 1.0, 1.x Aug 13, 2017
@stevengj stevengj changed the title parse \mapsfrom and rest of arrows block as infix operators parse \mapsfrom and rest of unicode arrows as infix operators Aug 13, 2017
@stevengj
Copy link
Member Author

One issue with some of the elements of the arrows block is precedence. Horizontal arrows are parsed with --> precedence, and vertical arrows are parsed with ^ precedence, but I wasn't sure what to do with things like or

@JeffBezanson
Copy link
Member

JeffBezanson commented Oct 15, 2017

Maybe leftward arrows should also be right-associative? (#24153)

@mschauer
Copy link
Contributor

mschauer commented Oct 16, 2017

Ideally if x ↦ y ↦ z is (x ↦ y) ↦ z then z ↤ y ↤ x should be z ↤ (y ↤ x).

@JeffBezanson
Copy link
Member

I was confused: all arrow-precedence operators are currently right associative. I believe that is standard both in logic and type notation (mumble mumble isomorphism). |> and <| have their own precedence level and are left associative, and arguably <| should be changed to right associative.

Currently everything in the arrows block with category Sm is parsed as an operator, which is good. For every remaining arrow character, we should either parse it as an arrow if it's obviously a sensible mathematical operator, or make it an invalid character. Then the invalid characters can be added as needed, if ever.

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 unicode Related to unicode characters and encodings
Projects
None yet
Development

No branches or pull requests

4 participants