Regarding "pass by reference", most people will say Java passes
objects by reference, when it is more accurate to say that they pass
object references by value. I don't think there is much confusion or
debate on that issue.

With Closures, there is a lot of confusion. Java has something
extremely close to closures, and only a real pedant can debate the
distinction. I also think when people say that Java lacks closures,
they are referring to first class functions and concise anonymous
function syntax instead.

"What you are describing, though, sounds like you really should jump
ship to one of the alternative languages."

That's actually a different issue: which language is a better fit for
a project. And I don't disagree, for functional programming support,
clearly Java is behind the pack. For this thread, I just wanted to
clarify what a closure is, and what people really mean when they say
that is missing from Java.

For your loop example, can't you simply do:

for (int x = 0; x < count; x++ ) {
        final int x2 = x;
    new Runnable() { public void run() {someFunctionOn(x2);}}.run();
}

or

for (int x = 0; x < count; x++ ) {
    someFunctionOn(x);
}

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