Understanding Templates: why can't anybody do it?

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Mar 17 13:29:18 PDT 2012


On 3/17/12, Entity325 <lonewolf325 at gmail.com> wrote:
> Who's with me?  Anybody have a short(but COMPLETE!) example of
> code that makes use of Templates that you actually understand
> what's going on there?

I wrote this a long time ago when I was just figuring out what
templates were about (it's not a general-purpose template tutorial but
just an explanation of a Phobos templated function that someone was
curious about):
http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/D2Templates

I had no idea what templates were when I started using D, and I
thought I would never need to use them either. But now I use them
extensively. They really become a natural tool in programming. They're
so nice to use that I never have to reach for the big fat OOP monster,
I can just write simple procedural code and use templates when I need
some flexibility.

In the meantime people have written some pretty good tutorials, like
Ali Çehreli's chapter on templates, and recently Philippe Sigaud's D
Template book. Those should be good resources on templates.


More information about the Digitalmars-d mailing list