Why does D not have generics?
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Jan 15 17:36:40 UTC 2021
On Friday, 15 January 2021 at 17:25:59 UTC, Paulo Pinto wrote:
> If it is instantiated T = void* then it would only be safe to
> use with pointers anyway, thus using T = object would be an
> option.
That's a minor detail though.
Overall, as long at D is based on GC I guess type erasure should
be done by the compiler for traceable pointers. Maybe I'll try
again for pointer-free libraries. Basically treating sequences of
bytes as values.
For instance, you don't really need to compare keys as double,
int or chars. You might as well compare them as 4 byte, 8 byte
etc sequences.
So for a B+tree you could use the same implementation for all
kinds of key types.
More information about the Digitalmars-d
mailing list