The RecipesBase.jl @recipe macro makes use of a couple special operators constructed out of ASCII characters, namely --> and :=. These character sequences seem to have some special attribute that allows them to be parsed into an Expr. Compare --> to --:
julia> 1 --> 2
ERROR: syntax: invalid syntax 1 --> 2
julia> 1 -- 2
ERROR: syntax: invalid operator "--"
julia> :(1 --> 2)
:($(Expr(:-->, 1, 2)))
julia> :(1 -- 2)
ERROR: syntax: invalid operator "--"
Interestingly, 1 --> 2 is parsed with an expression head of :-->, whereas other binary operators, including Unicode binary operators such as ↑ (typed as \uparrow + TAB), are parsed with an expression head of :call:
julia> dump(:(1 --> 2))
Expr
head: Symbol -->
args: Array{Any}((2,))
1: Int64 1
2: Int64 2
julia> dump(:(1 ↑ 2))
Expr
head: Symbol call
args: Array{Any}((3,))
1: Symbol ↑
2: Int64 1
3: Int64 2
So, I have a few related questions:
- What's up with
-->and:=? (EDIT: In other words, why are those character sequences specially parsed?) - Are there other sequences of ASCII characters that behave similarly to
-->and:=and that can therefore be used as operators in macros? - Is there documentation somewhere that lists the various "special" sequences of ASCII characters?