return-from-lambda viewed as dangerous, good alternatives
Mikael Grev
grev at miginfocom.com
Fri Jan 8 00:46:15 PST 2010
+ at least 1.
Mikael
On 8 jan 2010, at 00.17, Lawrence Kesteloot <lk at teamten.com> 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.
>
> Lawrence
More information about the lambda-dev
mailing list