& function shorthand revamp, and ./... argument placeholders #1070
Labels
partially completed
Some of the requested functionality has already been implemented
proposal
Proposal or discussion about a significant language feature
Based on Discord discussion, kicked off with a big idea from @STRd6:
&
precedence.
placeholder...
placeholder&0
,&1
, etc.&
precedence [DONE]Alternative wording:
Thus:
Note that the rule reasonably solves #85, allowing for things like
&+&
and[&, &]
. If you want two different functions, you need to separate them into different statements or calls. In the array example, we could write[(do &), (do &)]
. Or perhaps[&x, &y]
.Some of these examples are from #480, which I would view this as replacing. But some of those examples don't work:
These don't have a clear meaning with the new rule.
&
that can't be lifted is just($) => $
. We can't escape a function call this way. But we'll propose another way next!&
does get lifted one level when it's lonely like this, as in & function shorthand improvements #480. Feels a bit asymmetric. And wait for the next part!.
argument placeholder [DONE]At the top level of function arguments and array literals, we propose that
.
adds a magic function wrapper one level up:This gives us a form of partials and placeholders (#75):
...
arguments placeholderIn contexts where
...x
makes sense (function arguments, array literals, andobject literals),...
also adds a magic function wrapper one level up, but with multiple arguments:This gives us a function composition operator: to compose functions like
f >> g
in F#:If you don't worry about the extra wrappers, it's also a solution to "currying" (#818):
Multiple Arguments with
&
Back to
&
, we can now easily allow for multiple arguments too.&
acts like&0
,&1
accesses the next argument, etc.The text was updated successfully, but these errors were encountered: