Inverted syntax option

John Nilsson john at milsson.nu
Fri Mar 12 12:50:23 PST 2010


On Fri, Mar 12, 2010 at 9:02 PM, Lawrence Kesteloot <lk at teamten.com> wrote:

> I think this approach is interesting, and perhaps some of the issues
> could be worked out with clever type inference, but IMO it's a deal
> breaker that it's not clear what the extent of the lambda expression
> is. If you write:
>
>    foo(bar(baz(#1 + #2)));
>
> what is the lambda expression? It could be "#1 + #2" or "baz(#1 + #2)"
> or "bar(baz(#1 + #2))" and the compiler has to guess based on the
> parameters of these functions. The fact that it's not immediately
> obvious to the programmer what's being passed to what makes this a
> non-starter, as much as I like the nakedness of it.


Maybe it isn't so important. In some sense it shouldn't really matter, as
long as it type checks.

But it could be addressed with some optional delimiter:

foo(bar(baz(#(#1 + #2)))


I also suspect you
> would eventually miss the named arguments, since they help document
> the code.
>
This could be addressed with the previous proposals to support statements in
expressions:

(int a = #1; int b = #2; a+b)

BR,
John


More information about the lambda-dev mailing list