-
Notifications
You must be signed in to change notification settings - Fork 208
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
Should await
bind more tightly than postfix !
?
#319
Comments
If we make this change, then does that mean that
would be parsed as
? |
I keep coming up with reasons to prefer that we make
|
I think the two parsing concerns can be resolved; For
This doesn't resolve the To the rest of the concerns:
Fair point.
I think this is generally true, but not for
is valid code if you parse as In general,
I guess the example you have in mind is something like this?
Fair enough.
Good point. |
I'm with Paul. Let's keep it simple. In general, having precedence at all is sort of a "hack". It lets users omit explicit parentheses when composing some expressions, at the expense of making the actual order of evaluation completely hidden in the source text. Unless you've memorized the precedence table, you simply don't know how this will evaluate: a * b + c Any syntax feature that relies on material already being in the reader's head should be approached with caution. Keywords are somewhat OK because there's at least a word the reader can maybe infer some semantics from. If I've never seen Thus, I think we should try very very hard to stick to well-established precedence rules and avoid "innovating". We already got burned really badly with cascades. Parentheses aren't intrinsically bad. They make the code a little more verbose, but they make the precedence explicit, which is good for any reader who doesn't know the precedence. So, in this case, I think keeping the familiar precedence of other unspaced-postfix operators ( |
This all seems reasonable to me. Thanks for the discussion! Closing this, resolving in favor of treating this uniformly. |
If we simply make
!
a postfix operator using the existing grammar, I believe we get the behavior thatawait e!
is parsed asawait (e!)
. Sinceawait
is accepting ofnull
, it seems like it would be more useful to make it bind more tightly than!
, and hence treatawait e!
as(await e)!
. I'm not sure whether this matches the users intuition or not though. Would it be surprising to the user ifawait x++
were parsed asawait (x++)
butawait x!
were parsed as(await x)!
?Thoughts?
Issue raised by proposed tests here.
cc @lrhn @munificent @eernstg @stereotype441 @danrubel @bwilkerson @scheglov
The text was updated successfully, but these errors were encountered: