[linux-elitists] DOTGNU

Adam Sampson azz@gnu.org
Sun Dec 30 15:42:15 PST 2001


burton@openprivacy.org (Kevin A. Burton) writes:

> I have never needed a function reference in Java!  Give me an
> example of an application that you can't write in Java which needs
> function references.

That's not a terribly useful argument, since anything you can write
using function references can be rewritten without using them; the
same applies to any language feature as long as the language remains
Turing-complete. ;)

My major reason for wanting function references (and
anonymous/"lambda" functions) is so that I could program in a
functional style more elegantly[1]; I like using things like "filter"
and "map" on lists, and with current Java I have to use an anonymous
class to accomplish the same effect, even though I'm only implementing
one method within it. I'm not saying that anonymous classes aren't
useful---when you want _several_ callbacks, such as within Swing,
they're much more elegant than passing several function
references---but for most applications they're overkill.

> Since when is operator overloading good?  

When you're implementing a type for which the normal operations make
sense---for instance, large integers or strings. I'd rather not weaken
a language by leaving out a useful feature simply because poor
programmers might abuse it; Java's special handling of operator
overloading just for Strings strikes me as somewhat ugly, and I can't
help but feel that code written using BigInteger etc. would look much
nicer if the standard operators could be used.

- Adam

[1] Elegance is in the eye of the beholder; insert "in my opinion"
freely in the above text.

-- 
Adam Sampson <azz@gnu.org>                  <URL:http://azz.us-lot.org/>



More information about the linux-elitists mailing list