Summary: Lambda syntax

Alex Blewitt alex.blewitt at gmail.com
Fri Mar 19 05:54:08 PDT 2010


On 19 Mar 2010, at 11:00, Stefan Schulz <schulz at the-loom.de> wrote:

> Am 19.03.2010 01:04, schrieb Alex Blewitt:
> Fixed 7 and 17 (had "Throws" instead of "Exceptions").
> In 16 I don't see any error. As the examples (unfortunately?) only  
> always have at max one exception, there is no need for pipes.

16. Rémi Forax, 14 Mar 2010

FunctionType:
     ResultType ( TypeListopt ) PipedExceptionsopt

Examples:
int()
String(File) throws IOException
R() throws E (R(A) throws E, A)
>

I interpreted that as having two comma separated exceptions, but if  
that isn't the intent then the mistake is mine.

>> In addition, the example with "new" probably shouldn't be included
>
> The new word is part of the syntax (cf. to Howard's post).

The use of "new" isn't a syntax issue; it's a semantic error in the  
laguage. Whilst trivial examples may hint that a JVM should be able to  
in-line, in practical cases (returning the lambda from the function)  
will not be able to make such guarantees, particularly due to identity  
issues (like the possibility of .wait() and .notify() on a lambda)  
which have specific meaning on the case of new'd things in Java.  
Experience in codebases using inner classes as closures (and lambdas  
too) suggests that excessive new'ing of such items and returning  
causes significant churn in the new generation space, to the extent  
that assigning such lambdas to static final variables had to be done  
to avoid this behaviour.

In other words, this approach has already been demonstrated not to work.

Alex


More information about the lambda-dev mailing list