The topic of template instantiation has come up many times on the D newsgroup. But the topic of template instantiation doesn't come up nearly as often since implicit function template instantiation ( IFTI) was added.
It used to be described in the D specification that templates must be explicitly instantiated such as
For a long time I felt that implicit function instantiation of templates was where C++ templates ran off the road into the weeds. Certainly, I still feel that way about overloading them with regular functions of the same name, but I'm not so sure about the rest. I still loathe things like implicitly instantiating template functions by taking their address, mainly because it is a b*tch to get to work right in a language that fundamentally does bottom up typing (this kind of instantiation is top down, and so where they meet is a swamp of bugs).
Implict instantiation is an enormous increase in complexity.
- Name<ARG>, NG:D/19594 by Heretic
- Criticism: NG:D/19603 by Andy Friesen
The trouble with Name<ARG> is (as I understand it) that it requires semantic analysis to figure out whether < and > are being used as angle brackets, or as greater-than/less-than in an expression. Plain-old parenths might cut it, but that makes what's going on less obvious. Braces already have meaning as well. I agree that template instantiation should be much less verbose; it's just a matter of working out a good syntax for it. -- andy
- Criticism: NG:D/19604 by Ben Hinkle
Plus in C++ "foo<bar<T>>" needs to be "foo<bar<T> >" with a space between the last two >'s since >> is the right-shift operator. This is a nasty gotcha.