return-from-lambda viewed as dangerous, good alternatives
Mike Swingler
swingler at apple.com
Thu Jan 7 16:28:46 PST 2010
On Jan 7, 2010, at 4:17 PM, Lawrence Kesteloot wrote:
> On Thu, Jan 7, 2010 at 3:46 PM, Peter Levart <peter.levart at gmail.com> wrote:
>
>> I think you're exaggerating. The possibility that someone would mistake lambda expression for a
>> method is near zero. Lambda expressions do begin with a special character '#' that stands out.
>> Methods are 2nd level constructs (if class declaration is 1st level), lambda expressions are
>> expressions - they appear in places where you won't find any methods. You don't mistake nested
>> blocks of for/do/while/if for methods, do you?
>
> I think most Java programmers will think of closures as a more terse
> version of anonymous inner classes (like CICE). They will consider
> these two bits of code equivalent:
>
> Thread thread = new Thread(new Runnable() {
> public void run() {
> if (shouldDie()) {
> return;
> }
> ...;
> }
> });
>
> and:
>
> Thread thread = new Thread(#() {
> if (shouldDie()) {
> return;
> }
> ...;
> });
>
> With full transparency you're going to be fighting people's
> preconceived notions of how anonymous functions behave in Java. 15
> years of UI design has taught me that if you fight a user's mental
> model, you lose, and documentation doesn't help.
I couldn't have said it better myself.
Cheers,
Mike Swingler
Java Runtime Engineer
Apple Inc.
More information about the lambda-dev
mailing list