howard.lovatt at gmail.com
Tue Jul 13 00:51:35 PDT 2010
I favour using return instead of yield or another keyword for lambdas
since I think that it is a better fit with Java, i.e you get the
behaviour of an inner class which is the most natural way.
Additionally, people will be continually refactoring between inner
classes and lambdas and having different behaviour will be most
The most import ant point are the two above, but additional points in
favour of return and inner class behaviour are:
1. Just because some other language has particular semantics doesn't
mean Java should, it is much more important that Java is self
2. The term lambda comes primarily from Church's Lambda calculus,
which didn't have return, break, continue, objects, methods, etc. so I
find the argument that it must behave exactly like Church's construct
weak since that would imply that we should eliminate return, break,
continue, objects, methods, etc. and no one would want that.
3. If you change Java to allow long returns, say "methodName.return
value;", and allow this to always be used and say that an unqualified
return is a shorthand that returns from the inner most method or
lambda then this is transparent (so long as you use the named return).
Therefore long returns and transparency can be added in future if
required (I suspect they wouldn't be required).
4. To me the odd constructs are the loops, if, and blocks, because
they don't return a value. I am not suggesting this change for Java
because it would be too hard, but imagine that you used return inside
all blocks like you do a method to early terminate the block and to
optionally return a value. Then you wouldn't require the ?: operator
or continue (return would do this). To me, this use of return would be
much more consistent than the Lisp/Smalltalk type blocks anyway.
More information about the lambda-dev