Templates everywhere

Nick Sabalausky a at a.a
Sun Mar 14 11:37:40 PDT 2010


"Philippe Sigaud" <philippe.sigaud at gmail.com> wrote in message 
news:hnitl9$1kpg$1 at digitalmars.com...
>I was looking at some of my code today, I was surprised to see it was 
>almost 100% templated: functions, mixin, structs, 'real' templates, what 
>have you. Apart from main, what I write these days is full of (U,T...) if 
>() {} and templates of templates of templates.
>
> That's quite an evolution, because when I discovered D 2 years ago coming 
> from C++, I only used foreach and dynamic arrays. In C++, I never had any 
> reason to create my own templates and couldn't wrap my head around 
> anything template-y more complicated than 'containers of T'.
>
> Today I think in templates (well, at least I try to...). So:
>
> 1- thanks Walter for opening new vistas to me. Doing templated code in D 
> is so fun and powerful that you transformed forever the way I look at 
> problems.
> 2- Do other have a similar evolution?
>

"Do other have a similar evolution?"

As far as D specifically, the only evolution in me I can think of is this 
nice habit of being able to deal with code without getting absolutely fed up 
every three minutes (I had come from C++). It has also gotten me in the 
habit of certain good practices (like generic programming, for instance) 
which I [try to] bring with me as much as possible when I have to use a 
lesser langauge.

I have had other things in the past though. When I first moved from BASIC to 
C (forever ago) I couldn't understand the usefulness of pointers (all the 
examples I saw in books seemed to do nothing more than create a redundant 
alias for a varaible that already existed in the same scope). Then I read 
some books about game development (on DOS), which involved a lot of storing 
data in buffers. That got me to understand how (at least in C) an array is 
just a pointer to a buffer but with prettier syntax, and then it all finally 
clicked.





More information about the Digitalmars-d mailing list