Inverted syntax option
bobfoster at gmail.com
Mon Mar 15 12:09:22 PDT 2010
John Nilsson wrote:
> On Fri, Mar 12, 2010 at 9:02 PM, Lawrence Kesteloot <lk at teamten.com>
>> ...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
> (int a = #1; int b = #2; a+b)
Perhaps you meant this to illustrate how awkward and regressive this
numbered-argument syntax is, and if so I applaud you for the examples.
If this is a serious proposal, I suggest swapping the % character for # (the
parser can figure it out by its prefix operator position) so everyone will
understand that the new model for the Java language is the MS-DOS command
baz(%1 + %2)
More information about the lambda-dev