Java-like generics in D
Regan Heath
regan at netmail.co.nz
Sun Aug 12 15:31:07 PDT 2007
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?
I wonder if the proposed D macro feature might help implement this sort
of thing...
Regan
More information about the Digitalmars-d
mailing list