I have an idea of how to get the advantages from a similar syntax without the mentioned disadvantages.
- You can:
- Make to use
$
before the lambda scope (before{
) - Make to start the name of the parameter with
$
- Make to use
- Why this helps:
- I can not accidentally mix up common captured variables and implicit parameters (now it is insensitive to them)
- I can guess from such implicit parameter what it is (not like
it
that can correspond to anything in the world) - Syntax is still laconic
- It is also insensitive to nested lambdas parameter names:
- Lambda, marked as
$
must use one (not 0 or 2+) new implicit parameters. - So, when you would try to rename 2 parameters such way that they have the same name, You would have compilation error.
- Actually, that is not real insensitivity, but there is no implicit converting from
(X) -> T
to() -> T
or something like that. - The attitude when there are collisions is similar to one when the explicit syntax is used, but here we get an error, but not just warning.
- Lambda, marked as
- Of course, using any of the approaches of implicit parameter name is bad when you have a big lambda.
- The comparison of syntaxes:
- Explicit
{ cat -> feed(cat) }
-
it
{ feed(it) }
- My idea
${ feed($cat) }
- Explicit
- The syntax may be simplified more I think
So what do you think of it?