Implicit return syntax error
Rémi Forax
forax at univ-mlv.fr
Thu Dec 10 15:15:31 PST 2009
Le 10/12/2009 23:46, JmH a écrit :
> Hello,
>
> Firstly my name is Jason Height and aside from using java for many years i
> have no formal experience in writing of extending programming languages.
>
> However, this does not prevent me from having an opinion!
>
> I just started reading the strawman proposal and i would like to discuss the
> benefit/reasons of having an implict return statement for the simple
> expressions. I actually believe for a person with little or no experience in
> closures that the statement "#()(return 42;)" rather than "#()(42)" is far
> more readable and natural when compared to the existing jls. A syntax error
> is be generated if one omits the "return" keyword for a function ie:
>
> public int getFortyTwo() {
> 42;
> }
>
> As such i propose that the straw man proposal should be changed to so
> implicit returns are syntax errors.
>
> Thanks for reading.
>
> Jason
>
>
Hi Jason,
Java syntax does a clear difference between expression and statement.
return is a statement not an expression.
The strawman proposal proposes two syntax:
- one for expression: #() (42)
- one for statement: #() { return 42; }
I don't think it's a good idea to try to blur this difference.
Rémi
More information about the lambda-dev
mailing list