Project Lambda: Java Language Specification draft
Neal Gafter
neal at gafter.com
Sat Jan 23 15:30:51 PST 2010
I like the dot version, and it need not be specific to closures. That
is, define the syntax
primary . ( expressions )
for SAM types to have the same meaning as
primary . invoke ( expressions )
where "invoke" is the name of the SAM's abstract method. For example
Runnable r = ...;
r.(); // calls r.run()
-Neal
On Sat, Jan 23, 2010 at 3:00 PM, Stefan Schulz <schulz at the-loom.de> wrote:
> 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