Re: Still no typedef
Robert M. Gary wrote:
On Dec 5, 10:16 am, Lew <l...@lewscanon.com> wrote:
Hunter Gratzner wrote:
You don't need typedef in Java, so there'd be no point to it.
C++ doesn't have generics, it has templates. Not even close to the same thing.
Well, I don't really have time to teach you C++ templates in this
thread but I think if you did some research you would have a better
understanding of what they do. Besides, I already tought one class on
this at the University you could have attended that or you can do your
own research.
Quite all right, I have certainly used C++ templates plenty in my C++ programming.
Now if the OP could show in concrete terms what a "typedef" might be in Java,
and how it would make any positive difference at all, we could have a
discussion. I am not seeing it - neither a reasonable definition of what a
"typedef" would be, nor how it would help.
I think as you gain experience in generics more in Java you will find
that by the time you delare the iterator, pass it a few classes for
its generic's parameters, then pass its contructor a container that
requires a couple of class for its generics description you will find
that declaring a single iterator can require more than one line of
code. Typedefs make this much cleaner.
I have been using generics for quite some time now. Since they came out, in
fact. I also constantly read material on their use, including frequent
re-reads of the Sun tutorials on the matter, and the JLS itself. My comments
were informed by that experience. Not that your /ad hominem/ remarks either
required a response or in any way addressed the points I made.
How about this declaration of an iterator and its use?
List <String> names = fillNames();
for ( String name : names )
{
System.out.println( name );
}
Yep. Generics sure made that verbose.
As I pointed out, the "extra" use of "String" (ooh, that one-word overhead!)
serves a purpose - to guarantee the type safety of the String operations.
You still haven't shown any example of how a Java "typedef" would work. How
about in the scenario I presented?
--
Lew