In Julia 0.6, the following is legal syntax:
ᵃx = 3
1+ᵃx # returns 4
But after #22089, it errors with "UndefVarError: +ᵃ not defined", because it parses as 1 +ᵃ x
.
One possible remedy would be to deprecate variable names that begin with characters that are allowed as operator suffixes.
Another option would be to require spaces around suffixed operators.
Or do both, with the options of removing the spaces requirement in a later version.
To be clear, it is only the letter sub/superscripts that are the problem here; the other operator suffixes are not allowed as the first character of an identifier.
This is another case similar to 1.+2
. Probably ok to make it an error like we did there. A bit unfortunate though, since superscript letters seem much more useful as part of variable names than on operators.
They're kind of weird as the first character in an identifier. At least in my mind +ᵃ
seems more reasonable then ᵃx
.
See also #20278 … identifiers starting with superscripts/subscripts aren't that common, but do appear occasionally in mathematics. It wouldn't be a huge loss to lose them in Julia, though, I guess.
We wouldn't necessarily lose them, we would just lose the ability to write +ᵃx
without a space to disambiguate +ᵃ x
and + ᵃx
—which just seems like a necessary disamgibuation anyway given that we want superscripts on operators and as the leading characters of identifiers.
Most helpful comment
We wouldn't necessarily lose them, we would just lose the ability to write
+ᵃx
without a space to disambiguate+ᵃ x
and+ ᵃx
—which just seems like a necessary disamgibuation anyway given that we want superscripts on operators and as the leading characters of identifiers.