-
-
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 '?' in variable and function names #22025
Comments
I would also really prefer writing predicates as |
Perhaps I'm extrapolating too much, but wouldn't the use of |
Yeah, its unfortunate this wasn't tackled earlier, but if it doesn't happen pre-1.0 will it ever? I think the change is warranted. If someone changes the parser, I'd be happy to hunt through |
I'd be in favor of requiring spaces around |
There's a surprisingly large number of instances of ternary operators without space after the |
I suppose the larger, and much more serious deprecation would be renaming of the predicates in the standard library should it be decided that following the |
One observation is that ternary |
Right, that's the other thing about this – it's a multistep deprecation:
I'm not sure that much underpants collecting is worth it. |
Ugh, when you put it that way, it sounds pretty painful... |
I know... not breaking people's code is a total drag 😬 |
Ok, so the question is: is it worth it? I still think that it is and as mentioned by @quinnj the deprecation of |
In other words: pleeeeeeeeeease :) |
Probably not. FWIW I actually like that we use Regarding |
It sounds like movement should be made toward deprecating ternary operators without spaces, regardless of whether |
I'd tend to think that should be something that a linter/formatter should catch rather than the language itself. |
True, if we get widespread adoption of a standard formatting tool then this kind of change becomes much smoother since we can just tell people to run the formatter on their code before upgrading. I think I agree that deprecating ternary without spaces is a good idea regardless, but if we don't end up claiming that syntax, then disallowing it for no reason is just a bit weird. |
This is already implemented for the |
Stefan - we've combined steps 2 and 3 in the past, no? That would be v0.7 (step 1) and v1.0 (steps 2+3). But yes, this needs to compete with nullables (prefix unary |
Yes, that's why they're in the same version (N+2). |
I think at this point it doesn't make sense to introduce |
We could deprecate identifiers followed by |
I also would like to raise the point that |
This issue seems in limbo, but just to chime in with my 2c: I think allowing To summarise, I think allowing
|
Tbh I've come around on this a bit. It is worth noting that omitting spaces in ternaries has been ¯\_(ツ)_/¯ |
Given that space in ternaries is now required (I see a syntax error with |
Is that correct? IIUC allowing Adding aliases for predicates like |
It is not 😄 |
The plan for |
If a shorthand for |
Allowing it in identifiers feels a bit wasteful to me. We already have the |
As I understand it, there are two competing desires here:
The alternatives which I suggested above were ... clunky. With the exception of How about julia> ~(T::Type) = Union{T, Missing};
julia> ~String
Union{Missing, String} Perhaps this isn't quite as nice as Regarding allowing
It works, I'm not so sure about well.
Even if there's little interest in changing the base functions, I'd think it would be worth at least allowing a Julia user to write identifiers with |
I imagine that any changes with this won't be happening soon, but @StefanKarpinski @ararslan might you have any thoughts on my comments above? |
imo, this is probably not worth it. |
Did something happen with this? |
My experience for any language in avoiding double-naming things (apparently among the hardest things in programming?) also points toward wanting And the consistency with And as a silly sidenote, when reading a function named e.g. |
Currently Julia does not support question marks inside of variable names. This was discussed a while ago , with support, but never pursued (#1539). The major implication of allowing this is that you can write predicate functions with a question mark. (eg.
integer?(x)
instead ofisinteger(x)
).A little more discussion can be found on discourse. I wish I could accompany this with an RFC-like pull request, but I got quite lost in the parser in my attempt.
If this is pursued I really think trailing question marks should be pursued as the convention for predicates. They indicate very clearly that the function asks a question and, as previously discussed, the
is-
predicates can be awkward, leading to inconsistent usage (eg.contains
).The text was updated successfully, but these errors were encountered: