The lambda conversion and a lambda body that doesn't complete.

Neal Gafter neal at
Tue Mar 1 09:35:38 PST 2011

Dear Lambdans-


*interface F {
    int invoke();

I would like to be able to write

*F x = #{ throw new Exception(); };

(Modulo syntax - whatever the current syntax is)

But according to the current draft specification that's not allowed (the
lambda as written can only be converted to a SAM with a void return type).

I think that whether or not the lambda's body can complete normally should
be taken into account in the lambda conversion to make this legal.  As a
point of information, the behavior I prefer is the behavior of Scala, BGGA,
and C# (among others).  This is also consistent with the way method
implementations work:

*int f() { throw new Exception(); }*

In the unfortunate case that you need use cases for this, draft
specification language, or suggestions for a straightforward implementation,
I can provide those.


More information about the lambda-dev mailing list