Re: Why Generics?
- From: "David Blickstein" <db@xxxxxx>
- Date: Mon, 09 May 2005 15:07:11 GMT
"Thomas G. Marshall" <tgm2tothe10thpower@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in message news:aMVee.3094$w56.2630@xxxxxxxxxxx
> If that's what you were worried about then enums were not "truly needed"
at
> all.
I agree with you, but only in the "possible" sense of "needed", not in the
"desirable" sense. In that sense of the word, your claim is already proven
by the fact that the new enumerations are (in my understanding) just a
little syntactic sugar provided by the javac compiler. So clearly type
safe enums were always possible.
However, you could say the same thing about the new enhanced "for"
statement. Yes, it's possible for me to to write a loop that is
effectively coding "for each element of this list", but (IMO) it is
substantially better to be able to CODE it as "for each element" rather than
"something that translates to for each element".
For example... which is more readable:
int sum = 0;
for (int i=0, i<a.length() ; i++) {sum += a[i]} ;
print(sum/a.length());
or:
print(average(a));
The problem with the example you gave (IMHO) is in what I call the
"exposition". The advantage of enumerations (and for each and a bunch of
the othernew features) is that they provide a syntax to DIRECTLY express a
basic operation, and thus expose the operation more directly.
.
- Follow-Ups:
- Re: Why Generics?
- From: Dale King
- Re: Why Generics?
- References:
- Why Generics?
- From: David Blickstein
- Re: Why Generics?
- From: Eric Sosman
- Re: Why Generics?
- From: Chris Uppal
- Re: Why Generics?
- From: Mike Schilling
- Re: Why Generics?
- From: Chris Uppal
- Re: Why Generics?
- From: David Blickstein
- Why Generics?
- Prev by Date: Re: Extreamly large Hashtable
- Next by Date: Re: multiple root nodes
- Previous by thread: Re: Why Generics?
- Next by thread: Re: Why Generics?
- Index(es):
Relevant Pages
|