Effectively final
Alessio Stalla
alessiostalla at gmail.com
Thu Aug 18 10:06:04 PDT 2011
On Thu, Aug 18, 2011 at 6:55 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> Sorry, Llewellen, wrong again.
>
> Lambdas are functions. Functions are not objects.
>
> You are right that as currently specified for Java SE 8, lambdas happen
> to always get SAM-converted to instances of classes. That's as far as
> you can take this statement.
Well, as currently specified, lambdas only exist at the syntactic
level; they're effectively syntactic sugar for anonymous inner
classes. So in a sense they are objects; they denote objects. If in
future the same syntax will be used to denote proper functions, then
they will be functions, but until then, I don't see how can you say
that lambdas are functions, since Java does not have functions.
> A good way to think of this is as a boxing conversion; the lambda gets
> boxed into a SAM. Currently, there is no way to denote the unboxed
> lambda, but that doesn't make them the same thing.
It's not just that there's no way to denote the unboxed lambda;
there's no way to represent it at runtime, either. Unboxed lambdas in
Java are a purely abstract idea, at least for now.
Alessio
More information about the lambda-dev
mailing list