-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow identifiers to start with category No (Number, other) #20278
base: master
Are you sure you want to change the base?
Conversation
(Of course, if you are perverse, this allows you to define e.g. |
Call me crazy, but many might expect |
We could certainly export However, it is quite common to have variable names like Identifiers starting with superscripts and subscripts also seems like a big win to me, since this is standard notation in a lot of areas (e.g. see hypergeometric functions). |
I am queasy with the pairing of this current behavior |
@JeffreySarnoff, the proposal does not imply As for allowing people to define |
One option would be to allow category No characters to start a variable name, but to require that the variable name also include non-No characters. i.e. allow This would be strictly more conservative … we could always allow Would that address your objections, Jeff? |
I've made this change more conservative as suggested above: identifiers can start with category julia> ½ = 2
ERROR: syntax: invalid identifier ½
julia> ½x = 2
2 |
Rebased; it would be nice to get a decision on this for 1.0, although since it is a non-breaking change it could technically wait for 1.1 or later. cc @ararslan. |
Marking for triage for a 1.0 decision but I agree that this could wait until after 1.0. |
Those are the magic words :) |
This PR was postponed for post Julia 1.0. Can it be revisited and a decision made? |
From triage: +1 to disallowing No characters by themselves. We also see no harm in allowing super- and subscripts, but we want to exclude the fractions for now so we can at least make some clear progress here. |
Ok looking at the full list (https://www.compart.com/en/unicode/category/No) there is quite a lot of stuff in that category, e.g. parenthesized numbers. So I would lean towards only adding the superscripts and subscripts. |
This PR allows identifiers to start with with numeric symbols in category No: Number, other, allowing you to have variables with names like
⅓
or⅞U
or¹x₂
. (CategoryNo
was already allowed in identifiers, just not as the first character.)This is a strict increase in the set of allowed identifiers, so it shouldn't break any existing code. And it seems inconceivable to me that we would ever allow category
No
to represent numeric literals etc., so we might as well allow them to start identifiers.I also added tab completion for the various "vulgar fractions," e.g.(added in #25980)\7/8<tab>
to get⅞
.