-
Notifications
You must be signed in to change notification settings - Fork 5
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 grouping parentheses as in (a?.b) interrupt short-circuiting? #19
Comments
In that peculiar example I think that
2 |
1 |
1 for me. |
To me 1 is the most intuitive - I would expect it to work the same way as the other short-circuiting operators mentioned. |
I have chosen option 1. |
So you prefer to throw a TypeError over returning |
There is no strong reason for one way or the other. So, arbitrarily choose the simpler and most consistent solution from the spec's point of view. Fixes #19 again
@Mouvedia Regardless of the semantics, there is hardly a practical reason to use parentheses in this situation anyway. |
There is no strong reason for one way or the other. So, arbitrarily choose the simpler and most consistent solution from the spec's point of view. Fixes #19 again
That is, should
be equivalent to
(1)
(a == null ? undefined : a.b).c
rather than
(2)
a?.b.c
, or(a == null ? undefined : a.b.c)
(as currently specced)?As currently specced, grouping parentheses are transparent w.r.t. Nil references: this is consistent with how References work, but it is not necessarily a desirable consistency, as the Nil reference is a spec mechanism that the average user does not need to know.
One may rather want to make the semantics more similar to how short-circuiting or conditional evaluation works with other operators that have such a feature, namely
||
,&&
, and? :
.Any feedback is welcome. What is more intuitive, (1) or (2)?
The text was updated successfully, but these errors were encountered: