Julia: parse \mapsfrom and rest of unicode arrows as infix operators

Created on 12 Aug 2017  Â·  8Comments  Â·  Source: JuliaLang/julia

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

parser unicode

Most helpful comment

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

All 8 comments

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.

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

julia> ↤ = 7
7

julia> ↤ + 2
9

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.

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.

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 ↺

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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Keno picture Keno  Â·  3Comments

iamed2 picture iamed2  Â·  3Comments

yurivish picture yurivish  Â·  3Comments

sbromberger picture sbromberger  Â·  3Comments

arshpreetsingh picture arshpreetsingh  Â·  3Comments