-
Notifications
You must be signed in to change notification settings - Fork 108
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
Alternative implementation idea using comma operator. #308
Comments
I have no idea reason to have it and we have already function foo() {
return (console.log('hi'), 1)
}
const result = foo() // output console log: 'hi'; result = 1 If you want |
I listed a few benefits in the OP, but I would be happy to answer any specific questions that you have. Also I am aware of the comma operator already, as I used it several times in the OP as well as explicitly referencing "the existing comma operator." |
I'm not sure about the benefits of this proposal, but it got me thinking though... What if... actionUri
|> %.tolower()
|> baseUri + %
|> await fetch(%)
|> JSON.parse(%) Would be similar to (let $= actionUri
,$= $.tolower()
,$= baseUri + $
,$= await fetch($)
,$= JSON.parse($)
) Not that much more noise if you ask me... Also you can use your own topic token as long as it can be an identifier. |
@Jopie64 I think it wouldn't work well with TypeScript as |
@Jopie64 That is what I'm proposing. I'm just using the |> operator to make the syntax closer to F# and reduce boilerplate. |
What exactly you mean by "achieving the pipeline functionality"? I'm asking because
|
This would become
Technically it does not. But, because the variables are scoped to the expression, you could just name them all |
Instead of making a pipeline operator we make an expression-scoped variable assignment operator, and then use the comma operator to achieve the pipeline functionality. I think this may give us the best of both worlds.
This lets you name variables like the F# style but also lets you use arbitrary expressions like the hack style. As an added benefit, you can access any previously defined variable like so:
Also because it uses the existing comma operator, any performance issues or conflicts with other proposals are pre-existing. The only performance hit would be from expression-scoped variables which I would think should be equivalent to this:
Side note: it would be nice if the |> could be used without commas, but that might be harder to implement:
The text was updated successfully, but these errors were encountered: