Why does D not have generics?

Petar Petar
Tue Jan 12 13:25:36 UTC 2021


On Tuesday, 12 January 2021 at 12:25:31 UTC, Dukc wrote:
> On Monday, 11 January 2021 at 18:23:20 UTC, Q. Schroll wrote:
>> [snip]
>
> I recommend you check out Atila's Github profile. I think that 
> he wrote something to address the shortcomings of D template 
> constraints. Also considering your way to think about design, I 
> think there's a good chance you're going to like Tardy and/or 
> Mirror.
>
> Keep in mind though that as Mirror isn't yet officially 
> announced, Atila probably does not consider it quite 
> production-ready yet.

Generics is a pure type system feature and no library can emulate 
it perfectly. As mentioned in my other post, by using D meta 
programming to implement things like Tardy, even in the best case 
we still can end up with different instances of functions, 
sometimes containing the same machine code, just because of a 
difference between template arguments. Yes, linkers can sometimes 
remove identical code, but why pay the frontend + backend 
compilation time cost?


More information about the Digitalmars-d mailing list