Java-like generics in D

Frank Benoit keinfarbton at googlemail.com
Sun Aug 12 10:56:45 PDT 2007


Radu schrieb:
> Why on earth should some one want to implement such a hack that Java
> generics are?
> I think you completely miss understand how templates (generic code) work
> and how bad the Java implementation is. On .Net at least they are more
> than just compiler syntactic sugar. So no, it does not make any sense!

Several times, i tried to use templates in D. And each time, again i
meet these problems:
- errors about forward reverences
- increasing executable size by massive template instantiation with
differnt types.

So my understanding is:
* templates are perfect to parametrize with primitives, where a
different type parameter generated different binary code. (optimized code)
* templates are used to make compile time features possible.

But if you make something like a simple container, they are not so nice.
 A generic would be more appropriate in this case. In this case i wish i
had that java hack available. Thats why i though generics as an addition
to templates could be a good thing.



More information about the Digitalmars-d mailing list