-
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
F#-style addition, lightweight "inline" arrows #93
Comments
I'm not sure how you'd enforce "must be immediately invoked" - but using a single |
@ljharb yeah, I have to think about that a bit more as well. One possibility is parsing restrictions, allowing it only as |
An alternative: |
I would be uncomfortable using |
I'm also not in love with introducing pipeline-only syntax; part of what I love about the current F#-style proposal is how little new syntax it introduces, although that does make it tough to solve the " |
This wouldn't be valid outside of You can think of let x = ...;
let y = (a -> a * 2 + f(a))(x) In general its the same behavior as |
I'm like 70-30 against. Additionally, I don't see much benefit for this compared to just using fat-arrows. We still have to type the |
I'd prefer if we can minimize the number of tokens we introduce to make the feature set easier to learn. From that perspective, the optimal solution would be one token for pipeline, and one token for partial application and/or pipeline placeholder. |
Closing this issue, as the proposal has advanced to stage 2 with Hack-style syntax. |
This idea is based on the example in the comment here: #89 (comment). Note: In the comment, ■ is used as a token placeholder to avoid bikehshedding on the actual token.
While some parts of this example could be converted into arrow-function syntax for the F# approach, we cannot concisely move
await
(oryield
) expressions into a different function, since the context for theawait
is the current function.One option might be to introduce a lightweight "inline" arrow syntax using
->
that does not actually create a function object, must be immediately invoked as if it were a function. Since it is not actually another function body, we could useawait
(oryield
) in the body of the inline arrow. For example, using this approach we could rewrite the above example using F# style pipes like this:While this could be limited to the RHS of
|>
, it could theoretically be expanded to be used in any expression:(a -> a * 2 + await f(a))(x)
.The grammar could be something like the following (though more time needs to be spent investigating necessary cover grammars):
The text was updated successfully, but these errors were encountered: