-
Notifications
You must be signed in to change notification settings - Fork 27
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
& function shorthand improvements #480
Comments
One challenge is the interaction with existing x:
a: &
b: & + 1 // Ex. 1
({x: {
a: $ => $,
b: $ => $ + 1
}})
// Ex. 2
$ => ({x: {
a: $,
b: $ + 1
}}) It seems like Just wanted to note this so we can figure out the edge cases. |
Good point. Alternate parses for that same example: // Ex. 3
{x: $ => {
a: $,
b: $ => $ + 1
}}
// Ex. 4
{x: $ => {
a: $,
b: $ + 1
}} I realize this is also related to #85. If we end up with Ex. 2 or Ex. 4, we should reconsider whether |
And this is how that example parsed by web playground: ({
x: {
a: ($) =>
$({
b: ($1) => $1 + 1,
}),
},
}); |
Presumably the recently-added |
Yes, it seems like we forgot about the ternary. Oops! |
Not even: I tried |
Replaced by the (now implemented) #1070 which lets |
Currently, the rule is: unary operators to the left of, and everything to the right of, a
&
symbol get wrapped into the function.The proposal (from Discord discussion on March 1) is to make
&
"go up a level" if there's nothing right before or after it, namely, when it's followed by a comma or closing bracket. Examples:None of these parse currently (except for the one already implemented).
I think we need to precisely define "go up a level", but I guess I'm imagining until a level of brackets or a function call, but also preceding unary operators and maybe stuff trailing the function call.
We also lack a notation forDealt with in #635.$ => $
, which is occasionally useful (e.g. forfilter
). With this notation,(&)
would still work well.Related: #75 (essentially partials; cf.
%
for generic pipe placeholder), and various proposals for&
escaping another level up (e.g.((&))
)The text was updated successfully, but these errors were encountered: