Delurking comments on the 0.1.5 specification
Neal Gafter
neal at gafter.com
Thu Apr 1 09:33:11 PDT 2010
Jim-
Good, helpful comments. Thanks! I have a few comments on your comments:
A throws clause is not necessary in the lambda syntax. For the same
reason that the type resulting from invoking a lambda isn't usually
made explicit in the syntax for a lambda expression, there is no need
for the programmer to specify a throws clause; the body throws
whatever the body throws.
There is more to the distinction between expression and statement
lambdas than mere syntax sugar. Expression lambdas can be
"transparent", in the sense of satisfying Tennent's Correspondence
Principle, while statement lambdas are not. See
<http://www.youtube.com/watch?v=0zVizaCOhME> for a discussion of the
importance of transparency, and
<http://gafter.blogspot.com/2006/08/tennents-correspondence-principle-and.html>
for how this impacts the syntax. Although project lambda will likely
not specify full transparency in jdk7, it would be better if the
chosen syntax can be extended to full transparency in the future.
Having a separate syntax for self-invocation doesn't solve the
problems that prevent recursive lambdas when "this" is defined as
referring to the innermost lambda expression. Since the result type
is not explicit, recursive invocations in a return statement (or in an
expression lambda) would still have to be forbidden.
Finally, (to your suggestion that we just pick some syntax for now and
move on) I should point out that project lambda could have started
with a working implementation of all features considered for inclusion
(except extension methods) in an already-completed openjdk project
(the "closures" project) even though there were areas that likely
required change, but mark Reinhold thought it better to wait for a
community consensus to emerge for the bikeshed's color on the mailing
list rather than to take the heavy-handed approach of selecting a
known quantity <http://mail.openjdk.java.net/pipermail/lambda-dev/2009-December/000122.html>.
Given that openjdk7 is scheduled to be "feature complete" in about
two months <http://openjdk.java.net/projects/jdk7/milestones/>, we
shouldn't have to wait long for Oracle's draft-final decision (and
implementation) on all of these issues.
Cheers,
Neal
More information about the lambda-dev
mailing list