return-from-lambda viewed as dangerous, good alternatives
jjb at google.com
Thu Jan 7 18:37:13 PST 2010
Hi. Let me say at the outset that though I disagree with you, I'm not
trying to be disrespectful, and I trust you won't take offense.
On Thu, Jan 7, 2010 at 1:16 AM, John Rose <John.Rose at sun.com> wrote:
> For the purposes of this list (lambda-dev), I want to make a clear argument
> against overloading the "return" keyword to denote a lambda result value, in
> addition to its denotations in current Java.
I don't think anyone is trying to redefine return. In Java return has always
meant "return this value (or no value)" from the invocation of this method.
I think that must be true whether the method is a lambda or or an ordinary
method. I just don't see a problem here.
.I also want to suggest a range of alternatives.
Since I don't see a problem, I don't see the need for a range of (complex)
> It's no good saying "Aha, but every lambda body is really a method in the
> VM, so the meaning of 'return' is unchanged." That's a category error.
> We're designing language here,
We're not designing a language, we're extending one, which is a very
different game. We must not violate our users' preconceptions. I believe
that Java programmers will expect a return from within a lambda to return
from the lambda, and I have anecdotal evidence to back it up. I presented
code snippets to large groups of people and had them guess at what they'd
do. The great bulk of them simply assumed that a return from within a
closure would return from the function it defined.
and it's a mistake to mix in implementation considerations and/or assume the
> writer of the code is thinking about such implementation considerations when
> the lambda is being written.
I don't think this is an implementation consideration; I think it's
fundamental. We're considering adding function types to the language, which
define functions (AKA methods). The return keyword will return from these
functions. It seems simple to me. I'm not trying to be obtuse or
disagreeable;I really do think that' the way the great bulk of our users
(Java programmers) will see this.
More information about the lambda-dev