-
Notifications
You must be signed in to change notification settings - Fork 25
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
Receiver operator vs ?
token
#32
Comments
I think other tokens would exhibit similar problems too, e.g. Another approach to solving this down the line, which I think would work with any symbol (even |
@FireyFly Like the idea of mandatory parenthesis for the receiver placeholder. It fits really well with existing ES design. It also removes limitations listed here: #21 (comment) If it's stated then almost every symbols could be candidates for this proposal. |
Hm interesting, I hadn't seen that issue/discussion. It seems @rbuckton suggested the same syntax in #21 (comment). I'm not sure whether my interpretation of the syntax matches the suggestion in that comment.. to clarify, I'm imagining It's dismissed as fragile syntax in that comment, but I'm not entirely sure why... it seems fairly reasonable to me. |
@FireyFly Your interpretation was mine. It feels natural to me. And right I forgot about this comment #21 (comment) but I think it should be reconsidered. In fact the |
@FireyFly my concerns about "fragility" were the cases where (?).x // use not part of an immediate call.
// If `(?).x()` is ok why isn't this allowed?
(?).x.y(?) // use not part of an immediate call.
// Cannot eagerly evaluate `x` for the partial call to `y`. For these cases you could still use arrow functions: (a => a.x)
((a, b) => a.x.y(b)) |
Hmm yeah, I could see that. Perhaps it's better to leave it unspecified to begin with, and see whether a lack of receiver placeholder is a problem in practice before specifying it. |
Please refer to #23 for further discussion. |
Reading the proposal, there are two sections that make sense independently, but in combination seem to be limiting the usefulness of the feature:
? in any expression, rather than just in ArgumentList, and runs afoul of visual ambiguity with the optional chaining proposal
.? may only be used on its own in an argument list
.If a different token was chosen (say, one that can't be a variable right now, like
*
or~
), it wouldno longer cause visual or semantic ambiguity with optional chaining, null coalescing or even ternary operators. And it would mean that down the line, the operator could be combined with some of those features.
Choosing
?
will likely permanently close the door on the possibility of supporting a receiver placeholder. There are also downsides like the visual confusingness of a semantically-valid and unambiguous expression likef?.g(?, a ?? b, c ? d : e)
.*
would be marginally better (even if the expression is over-complex anyway) -f?.g(*, a ?? b, c ? d : e)
Choosing
*
or~
doesn't have those downsides. And even supporting a receiver placeholder wouldn't be a requirement for when the proposal became a reality, it'd at least be possible further down the line, as well as more obviously different from the other uses of?
.The text was updated successfully, but these errors were encountered: