-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
Reserve keywords for Haxe 4.0 #7413
Comments
We don't need these If we want to have only generic coroutine implementation without the need to teach the compiler the semantics of specific coroutine types (like async/await, generators etc). |
Also |
IIRC in my (kotlin's :)) original proposal, only one keyword is needed, e.g. |
Does anyone have feelings about a replacement for |
Ideally we would have something like |
I'm not worried about name mangling because we have to sort that out for I'm not sure about unops because you want to distinguish |
Right, don't really want to go the C++ way and have a marker argument... Hmm |
Unless you're planning to make it I think aggressively reserving relatively common keywords would be good in that it'll allow adding their syntax without breaking changes (macros aside). It should be combined with a plan for allowing them in field names to reflect native APIs. My personal favorite would be to allow all keywords to be field names (kind of like it's done with |
@:op == operation |
In order to give proper syntax for overloaded operators, I think it would require a new keyword
There's also the problem of generating a valid function name. the parser could put the operation in @:op like it used to be and set the function name as empty "" , then the compiler would generate the name based on a common name "add" "sub" etc. + eventual numbering/suffixes if several declarations with different types. |
That limits the possibilities of operator overloading. E.g. prefix and postfix |
Maybe the keyword
|
I don't really see a problem with allowing an identifier for unops:
Do you think it's strange that it would be allowed for unops but not for binops? I find that fair... and I don't want to allow it for binops because then we have multiple syntaxes that mean the same thing. I also don't want to require it for binops because that seems pointless... |
Well we would only need an identifier to differentiate ++a from a++ , and I fail to see a compelling case when I want a++ it to do something different than |
@RealyUniqueName ah I forgot about postfix custom operators, maybe then we should follow @Simn proposal, would still not allow them for binops |
You never know the user's domain specifics :) |
Right,
That aligns quite nicely: If it's just the operator, we get the widest possible interpretation. And by adding identifiers you can restrict it to prefix or postfix for unops, and non-commutative for binops. It's also matches our current approach for Anyway, I'm gonna reserve |
Yes we should discuss this. I certainly don't want to encourage something like this, but I also don't want to make it unnecessarily difficult to match extern APIs. A problem is that it's easy to support Also, I can already hear @Gama11 cry in the distance if this is to be properly syntax-highlighted. |
I actually like to give operators descriptive names, the generated code is cleaner and you have a name to talk / search about etc. It's fine to have operators but a well named alias is a good thing imho. |
Might want to reserve |
As for coroutines, I've written some considerations here: nadako/haxe-coroutines#13 |
I'm not sure about protected given we are very unlikely to introduce it (our private is already protected in Java), and we wouldn't want to change the whole definition. Ok for async/await/operator, although I hate keywords :) |
Given that the only implementation somebody worked on doesn't use async/await keywords, I'll not reserve them for Haxe 4. |
Even if we don't implement them yet, we should reserve them already:
overload
operator
protected
The text was updated successfully, but these errors were encountered: