On Mon, Sep 12, 2011 at 3:32 PM, clay <[email protected]> wrote:
> A closure is when you define a function that "closes" over the local
> environment from which the new function is defined and can access
> local variables of that defining scope. Java absolutely does this.

The problem being that the local environment for the function you are
in in Java gets destroyed when you return from the function.  The
compiler will copy over final values into the new environment that you
create with an anonymous class, but the environment that exists as you
create this instance gets destroyed.  (Hence, requiring that any
variables exposed to the "closure" be final.)

That is, if we had true closure (even without first order functions),
you could declare two of them that communicated through a mutable
variable.  Correct?  (This is a legitimate question, not a rhetorical
trick.)

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to