Return Isn't Transparent

Artur Biesiadowski abies at adres.pl
Sat Jul 17 08:35:06 PDT 2010


On 17/07/2010 15:46, Howard Lovatt wrote:
> Then imagine that you could create a lambda that encapsulated the long
> return and you called it:
>
> int m() {
>    { ->  return 42; }.();
>    // Oops error - must return value from m
> }

Yes, java is not perfect language. Forgetting about lambda

int m() {
         if ( true ) {
             return 42;
         }
         // Oops error - must return value from m
}

Still, we have to live with it and accept the fact that sometimes 
compiler is bit too strict about requiring returns. Some people throw 
exceptions/errors in such places...

I do not see your example as a particular point pro or against 
'transparent' returns.

Regards,
Artur Biesiadowski


More information about the lambda-dev mailing list