On Tue, Sep 13, 2011 at 2:15 PM, clay <[email protected]> wrote:
> 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.
I think you'd be surprised by how often there is confusion over this
very point. :) (Granted, I think some of the escape analysis tricks
whereby scaler replacement happens just throws a giant wrench at this
one. I may be horribly abusing these terms.)
> 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.
I don't disagree that most people are more concerned with function
literals than they are closures. Doesn't change the fact that Java
doesn't have closures.
> For your loop example, can't you simply do:
There are many different ways I could have done that differently. I
wasn't off to produce a program that you could not do in Java. I
simply was showing what Java could do if it had closures. Much like I
can quite confidently say you can not write the following java
program:
public void addSomeMatrix(Matrix a, Matrix b) {
return a + b;
}
Of course you can represent the same thing with a.plus(b) most likely.
This gets ugly as sin if you are trying to move an algorithm into
java but want to use BigDecimal, for example.
--
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.