Java-like generics in D

Radu radu.racariu at void.space
Sun Aug 12 10:42:55 PDT 2007


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!

Radu

Frank Benoit wrote:
> As addition to the existing templates, i think java like generics would
> be very helpful for D.
>
> The generic could be like this:
> 1) use the new keyword 'generic' instead of 'template'
> 2) Typeparameter can only be object or interface types
> 3) the compiled code does not know the exact type of the instantiation
> parameter. (type erasure)
> 4) the compiler 'inserts' missing casts for the given instantiation type
> parameters
>
> Advantages:
> 5) "lightweight templates", because of no more object code duplication
> for new instantiations.
> 6) the compiler can generate the object code independantly of the
> intantiation code
> 7) no more errors like 'forward reference' for generic, because the
> generic can compile without the knowledge of the exact types.
>
> Does that make sense?
>
>   



More information about the Digitalmars-d mailing list