Inverted syntax option

John Nilsson john at milsson.nu
Fri Mar 12 11:31:08 PST 2010


On Fri, Mar 12, 2010 at 1:18 PM, Alex Buckley <Alex.Buckley at sun.com> wrote:

> I would call these "naked lambdas" since the expression with #
> parameters is shorn of a signature or delimiters like {..}. But you
> still have to pay the cost of a static type system, by casting the
> positional parameters in order to do anything interesting with them.
> This seems like an original, but really quite painful, idea.
>
Only if assigning to an Object reference.

I imagine most uses of lambdas will be in arguments to methods where the
argument type is specified. In these cases type inference should kick in and
dictate the type.

Given a method
<T> testThat(T t, (T)->bool pred){}

a call like

testThat(myObj, #1.aMethod() == null)

would be legal. And the type of #1 would be inferred to be the same as myObj

I do agree that naked lambdas is a better name though ;)

BR,
John


More information about the lambda-dev mailing list