transparent lambda

Rémi Forax forax at univ-mlv.fr
Wed Dec 30 08:30:35 PST 2009


Le 30/12/2009 17:01, Neal Gafter a écrit :
> On Wed, Dec 30, 2009 at 6:40 AM, Rémi Forax <forax at univ-mlv.fr 
> <mailto:forax at univ-mlv.fr>> wrote:
>
>     You can also use 'return' as a suffix and the name of the function
>     (in a separate scope) as prefix.
>
>     int f() {
>       lambda() {
>         f.return 42;
>       }.invoke();
>     }
>
>
> You could, but the resulting construct is not TCP-transparent.


Yes, I see a lambda as an anonymous function and not as an abstraction
over a statement or an expression.
That's why 'return' returns from the lambda and not from the function.

In my opinion, lambda are more like anonymous class but for function.
So like you use Outer.this in an inner class to access to the enclosing 
class,
you should use f.return to return from a named function in an anonymous
function.

Rémi


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20091230/2bacbf50/attachment.html 


More information about the closures-dev mailing list