Expression syntax

Neal Gafter neal at gafter.com
Thu Nov 19 15:53:47 PST 2009


Paul-

For expression lambdas, you can certainly use parens if you find it more
clear:

*#int(T) p = #(T t) ( t.m() )
*

Since expression lambdas are at the topmost level of the precedence
hierarchy, I think there are few problems reading code even without the
parens.

Cheers,
Neal

On Thu, Nov 19, 2009 at 9:21 AM, Paul Benedict <pbenedict at apache.org> wrote:

> Thanks for reminding me of the previous version ;-) Okay. I think the
> braces are an obvious delimiter that's helpful for reading, but I give
> the benefit-of-the-doubt to Neal that he's gone through the thought
> process and made the right trade-off. If Neal/Remi know of any other
> possible way, maybe they could share it.
>
> Paul
>
> On Thu, Nov 19, 2009 at 11:17 AM, Zdenek Tronicek <tronicek at fel.cvut.cz>
> wrote:
> > This is exactly the previous version of the closures proposal. There, the
> > closure returned the value of the last expression. But there were two
> > "problems" with this approach: 1) it was a concept which were not used
> > anywhere else, 2) you could not return a value before the end of closure.
> >
> > Z.
> > --
> > Zdenek Tronicek
> > FIT CTU in Prague
> >
> >
> > Cituji Paul Benedict <pbenedict at apache.org>:
> >
> >> On Thu, Nov 19, 2009 at 10:57 AM, Zdenek Tronicek <tronicek at fel.cvut.cz
> >
> >> wrote:
> >>>
> >>> Braces are not optional here because they distinguish between
> expression
> >>> and
> >>> statement lambda:
> >>>
> >>> #int(T) p = #(T t) t.m();  // expression lambda
> >>> #int(T) p = #(T t) { return t.m(); }  // statement lambda
> >>>
> >>> I think this is a good choice because previous syntax (when the closure
> >>> returns the value of the last expression) was confusing.
> >>>
> >>
> >> Okay, so let's take this example. How is it substantially different
> than:
> >> #int(T) p = #(T t) { t.m(); }  // expression lambda
> >> #int(T) p = #(T t) { return t.m(); }  // statement lambda
> >>
> >> Couldn't the lack of "return" indicate such?
> >>
> >> Paul
> >>
> >
> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/closures-dev/attachments/20091119/10431296/attachment.html 


More information about the closures-dev mailing list