I think it would look nice to have up and down arrows in some function names that compute upward and downward propagating properties, but I’m getting errors when I try to use them. In my REPL, when I try
test↑(x, y) = x + y
I just get
↑ (generic function with 1 method)
as if the arrow were the whole function name.
When I try to use arrows in module functions, I get errors like
LoadError: "expected \"end\" in definition of function \"schwarzschild\""
or
LoadError: "invalid character \"⇈\" near column 23"
The parser file linked by @pbayer shows which Unicode characters are recognized as operators. This includes ↑ but not ⇈ and ⇑. Note that these characters have different Unicode categories:
Variable names must begin with a letter (A-Z or a-z), underscore, or a subset of Unicode code points greater than 00A0; in particular, Unicode character categories Lu/Ll/Lt/Lm/Lo/Nl (letters), Sc/So (currency and other symbols), and a few other letter-like characters (e.g. a subset of the Sm math symbols) are allowed. Subsequent characters may also include ! and digits (0-9 and other characters in categories Nd/No), as well as other Unicode code points: diacritics and other modifying marks (categories Mn/Mc/Me/Sk), some punctuation connectors (category Pc), primes, and a few other characters. […] Most of the Unicode infix operators (in category Sm), such as ⊕ , are parsed as infix operators and are available for user-defined methods (e.g. you can use const ⊗ = kron to define ⊗ as an infix Kronecker product).
So ↑ being parsed as a binary operator is expected
On the other hand it is suprising that ⇈ and ⇑ are not allowed as identifiers, since they have category So. Maybe file an issue?
I want to use ⇑, ⇘, etc., as variable names. It looks like this should be allowed by the variable naming rules but I get an error:
julia> ⇘ = 1
ERROR: syntax: invalid character "⇘" near column 1
It doesn’t look like ⇑ or ⇘ should be parsed as an operator; neither of them occurs in JuliaLang/julia/blob/master/src/julia-parser.scm .
They are both in the category So which is supposed to be a valid character for a variable name:
I want to use ⇑, ⇘, etc., as variable names. It looks like this should be allowed by the variable naming rules but I get an error:
julia> ⇘ = 1
ERROR: syntax: invalid character "⇘" near column 1
It doesn’t look like ⇑ or ⇘ should be parsed as an operator; neither of them occurs in JuliaLang/julia/blob/master/src/julia-parser.scm .
They are both in the category So which is supposed to be a valid character for a variable name:
I don’t know where “the rules” are described (other than in the source code), but you can use Meta.isidentifier() to check whether a string is a valid identifier.
My reading of that is that it’s a subset of Unicode code points greater than 00A0, and in particular the subset comprises all of the code points with “Unicode character categories Lu/Ll/Lt/Lm/Lo/Nl (letters), Sc/So (currency and other symbols)” and so on.