On Thursday, 22 August 2013 at 07:59:56 UTC, qznc wrote:
There are basically two ways to implement generics. Type
erasure (Java,Haskell) or template instantiation (C++,D).
Instantiation provides better performance, but sacrifices error
messages (fixable?), binary code size, and compilation
modularity (template implementation must be available for
instantiation). Type safety is not a problem in either approach.
See this brief discussion from Greg Morrisett on the topic, with
a finer subdivision of approaches
http://www.eecs.harvard.edu/~greg/cs256sp2005/lec15.txt
that confirms your bad news that monomorphization (C++/D
templates) and separate compilation won't play well together. Nor
do monomorphization and some advanced type system features work
together, but that's less of a worry for D.
That said, I like the D approach of putting a lot of power in the
macro-like template system. I worry more about the reliance on GC
in a systems programming language, as historically that's been a
losing proposition.
-- Brian