On Wednesday, July 16, 2014 3:40:31 PM UTC-4, Ben Arthur wrote:
>
> julia> const ∪ = union
>
∪ is already defined to union in Julia.
julia> const ¬ = !
>
> ERROR: syntax: invalid character "¬"
>
The ¬ character (U+00AC) is in category Sm (math symbols), and Julia does
not allow all possible math symbols as identifier characters. The reason
is that, for each math symbol, we need to individually decide whether it
will be parsed as part of an identifier or as an operator. And, if it is
parsed as an operator, we need to decide the precedence.
In consequence, there is a whitelist of math symbols allowed in identifiers
https://github.com/JuliaLang/julia/blob/master/src/flisp/julia_extensions.c#L51-L93
and another whitelist of symbols treated as operators
https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm#L6-L22
Both of these lists will probably grow over time.
In the case of ¬, I think it would make sense to parse it as a prefix
operator (with the same precedence as !), and probably to define
const ¬ = !
I actually thought about ¬ when I recently whitelisted a bunch of unicode
math symbols in Julia. My hesitation was that I'm not sure what useful
purpose ¬ would serve in Julia code, other than as a synonym for !. It's
not any shorter than !, and in general in Julia we have tried to avoid
introducing redundant syntax (e.g. "and" and "or" synonyms for && and
||). Following the "when in doubt, leave it out" philosophy, I therefore
left ¬ out of the patch.
However, if an argument can be made for the utility of ¬ in Julia, it would
be easy to include.
--SGJ