On Tue, Sep 13, 2011 at 11:31 AM, 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 already did. Here, spot the closure in Scala:
def printNumbers(max:Int) {
for( x<- 1 to max) {
println(x)
}
}
It isn't enough that the closure could get a copy of x from the
environment, it has to capture mutations to it, as well. Can you
accomplish the same thing with other means? Of course. (And,
someone please correct me if I am wrong on this.)
> I can articulate exactly why C doesn't have real objects. You can do
> OO style programming in pure C, and you design your code as "objects"
> in the conceptual sense, but you don't have language level support for
> it.
I articulated exactly what would be necessary for Java to have
closures. That you think it counts to modify the program to use
different objects shows that you aren't actually getting the argument.
This would be like saying Java has "pass by reference" because I can
do the following:
public void swap(Foo a1, Foo a2) {
Foo tmp = new Foo(a1);
a1.setValuesFrom(a2);
a2.setValuesFrom(tmp);
}
Sure, you can "swap" elements in this way. But this is not what pass
by reference means.
I'm sympathetic to both arguments. Hell, I incorrectly call java pass
by reference all the time. I get called on it and sometimes I try and
backpedal what I meant and claim I was correct. The fact is that it
is not pass by reference, no matter how well I know what I meant to
say, to claim otherwise is wrong.
And this is ignoring the fact that anonymous inner classes have not
been there since day 1.
--
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.