On 02/24/2013 05:20 PM, Andrei Alexandrescu wrote:
On 2/24/13 1:50 PM, Timon Gehr wrote:
On 02/24/2013 04:59 AM, Steven Schveighoffer wrote:
...

D is much different (and better IMO)
...

IMO The best way to think about it is that the two approaches are not
comparable. D templates are a kind of hygienic macro system for
declarations. Java does not have this. Java generics make the type
system more expressive. D lacks this kind of expressiveness.

I'd think type erasure techniques make it possible to emulate Java's
generics in D,

The compile-time type checking and avoidance of type erasure in user code aspects are the only important features of Java generics. This is most obvious noting that pre-generic Java also supports the techniques you mention.

 whereas D's templates can't be emulated in Java.


If type erasure is considered a means to emulate generics in D, then IMHO copy pasta should also be considered a means to emulate templates in Java. Otherwise the viewpoint could be considered biased. But I think usually they just use external code generation frameworks.


Reply via email to