-
Notifications
You must be signed in to change notification settings - Fork 107
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
Comma-based syntax #179
Comments
That meaning is still “a list of expressions” since variable declarations are expressions. it would be very strange if the expression |
There's an interesting comment by @masaeedu, #96 (comment), pointing out that in the current proposal, |
@ivan7237d That was a misunderstanding based on reading it with the wrong associativity. |
Closing this issue, as the proposal has advanced to stage 2 with Hack-style syntax. |
It's a simple idea, so probably came up before in some discussion and was rejected, but since I couldn't find it discussed after searching through all the issues, let me bring it up here.
The idea is that instead of
x |> a |> b |> c
, the syntax would bex |> a, b, c
. There are two reasons behind this syntax:As with ponyfills like
applyPipe(arg, f1, f2, f3)
, you will not have to put arrow functions in parens. Precedence-wise,a => b |> c
would meana => (b |> c)
.a |> b => c, d
can only meana |> (b => c), d
.Sometimes it's convenient to compose functions without applying them. Right now you can do this with a function like
pipe(f1, f2, ...)
, and it's conceivable that in future there would be a separate JS operator for that. Either way, preferably it should be easy to move function chains back and forth between usages in function composition, and usages with pipeline operator. When these chains uniformly use the comma as the separator, this is taken care of.I suspect there are some footguns or other flaws here, but the only one I see right away is that one could confuse the commas for the comma operator. A comma already has special meaning in contexts like
let a, b
though.The text was updated successfully, but these errors were encountered: