-
Notifications
You must be signed in to change notification settings - Fork 3
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
Applience LHS only to the last token of RHS #7
Comments
This is not what's intended by that code. We're attempting to remove the need for paren'd arrow functions here: tc39#104 and I don't think anyone would expect You're also still looking at this from the perspective of syntax and not what things are. Pipeline is not series of parentheses transformations, and it doesn't really make sense to explicitly implement it as such. |
I'd strongly suggest taking a read through the spec itself to get a sense for how things are defined. I think you'll find it difficult to impossible to actually spec something as a series of parentheses transformations. |
Sorry for not being explicit enough. I mean that such behavior is the reason why usage of arrow function without parenthesizes should be forbidden. But it's a bad formulation There is a way to tune the formulation a little bit and this issue would be resolved as well - apply LHS not to the last token of RHS but to the last element of RHS in the same scope. In this case And the question of parenthesizes is getting out of the scope of this discussion But if the current plans are to remove the need of parenthesizes then this is really become too complex to be |
I would like to propose a slightly different way of thinking about the F#-style pipeline operator
Its naive interpretation may sound like "take the left side and move it to the right parenthesized". What literally mean
It's about changing the target of the appliance of LHS from RHS to the last token of RHS. It would allow to solve some problems of current interpretation and make it more ergonomic:
x |> await f
expression. Because of its ambiguity in the current implementation, it is treated as a Syntax Error. Ifx
would be applied not toawait f
but only tof
there would be no ambiguity andx |> await f
may become a valid expression that would meanawait f(x)
await
-x |> await |> f
. Current interpretation treatsawait
in the pipeline as a unary function while in all other places of the language it's a unary operator. Because this use case would be covered withx |> await f
thex |> await
may become a Syntax Error andawait
in the pipeline would become a unary operator just like anywhere elseDefinitely, something that is far-far away from what it expects to be. And it will get a real sense only with parentheses
now it's IIFE! Everyone knows that parentheses are required for IIFE. From some redundancy that was required to escape ambiguity, they become non-questionable part of an actual logic
It should not conflict with any other part existing proposal
The text was updated successfully, but these errors were encountered: