What is the meaning of this?
Joshua Bloch
jjb at google.com
Tue Feb 2 14:08:40 PST 2010
On Tue, Feb 2, 2010 at 10:40 AM, Neal Gafter <neal at gafter.com> wrote:
> I think Zdenek had it exactly right.
>
> A lambda expression is not an object creation expression.
This claims is ludicrous on the face of it. Is a lamda an expression? Yes.
Does it "create" (i.e., furnish) an object (which may or may not be new)?
Yes. So it's an object creation expression. As far as I'm concernect,
that's all there is to it.
The function is not declared within the scope of some object type. A
> lambda is written as an independent block of code, and should be scoped
> accordingly.
You're creating an instance of an object. It has a type. Not scoping it
accordingly is asking for trouble.
> Trying to make a lambda act the same as an anonymous class creation
> expression smacks of cargo-cult language design.
>
Doing something because its the way a bunch of other languages did it is
cargo cult language-design (in the absence of other good arguments). Trying
to match the syntax and semantics of existing constructs in the language
you're proposing to extend is a best practice. Unlike cargo-cult design,
it's very easy to argue why it's a good idea: it keeps the conceptual
surface area of the language from growing--this one's already too big--and
it avoids programmer astonishment and errors. It allows people to reason
about the new construct using knowledge they acquired from using existing
constructs.
Josh
More information about the lambda-dev
mailing list