Project Lambda: Java Language Specification draft

Stefan Schulz schulz at the-loom.de
Sat Jan 23 15:00:18 PST 2010


On 23.01.2010 17:43 Stephen Colebourne wrote:
>>   #int(int) doubler = #(int x)(x + x);
>>   assert doubler!(fortyTwo!()) == 84;
>
> I find the ! invocation pretty darn ugly I'm afraid. I can't help
> reading "not". The symbol also blends into the brackets visually.

I had the same association with "not".

>   assert doubler.invoke(fortyTwo.invoke()) == 84;
>
> The simple approach is more verbose and explanatory, which is quite in
> the style of Java.

While I, as others, prefer the method-like invocation style, as it seems 
to be quite complex to solve issues with namespaces and such (at least 
in the time frame for JDK7), why not use a Java-like way to invoke a 
lambda? Maybe a shorter name than "invoke" would help:

   assert doubler.with(fourtyTwo.with()) == 84;
   assert doubler.on(fourtyTwo.on()) == 84;

Or use ^ with a (maybe far-fetched) resemblance of a lambda character:

   assert doubler.^(fourtyTwo.^()) == 84;
   assert doubler^(fourtyTwo^()) == 84;

(where the latter may be tricky to spot and distinct from exclusive or 
by a human reader).

Cheers,
Stefan


More information about the lambda-dev mailing list