On Tue, Sep 13, 2011 at 17:31, clay <[email protected]> wrote:
> "This breaking news, just in: C has objects, and Lisp has static
> types."
>
> Rather than all the snarky replies, how about you actually explain
> what makes the Closure-like functionality in Java not really true
> closures?

I'm not the O.P, but I'll take a swing:

"Full" Closures capture the lexically scoped *variables* at the time
of closure creation. Changes the closure later makes to those
variables when it is run will be visible to any other closure that has
captured those same variables. (Let's call this "communication by
mutation".)

Java's anonymous inner classes copy the *values* bound to lexically
scoped variables at the time of object instantiation. You can achieve
up "communication by mutation" by an additional level of indirection:
just let your variable hold a reference to something that is mutable.

In languages where variables are immutable, such as Clojure, this is a
distinction without a difference.

The fact that Java's AIC only copy values and don't capture variables
is something I don't lose sleep over since I try to avoide mutability
where I can.

// ben

-- 
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