Nobody understands templates?
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Mar 4 10:27:26 PST 2014
On Tue, Mar 04, 2014 at 06:19:38PM +0000, Chris wrote:
> On Tuesday, 4 March 2014 at 15:52:37 UTC, H. S. Teoh wrote:
> >On Tue, Mar 04, 2014 at 10:32:52AM +0000, Chris wrote:
> >[...]
> >>Maybe that's why it is so hard to see the benefits of templates,
> >>because many cases (of abstraction) are already covered by OOP. I
> >>like templates, but I'm not sure if they are as useful as D's
> >>ranges. Ranges and component programming handle the ubiquitous
> >>input>filter>output paradigm present in every program and help to
> >>break down the program's logic into digestible chunks, a logic you
> >>cannot just copy and paste (but you can reuse the chunks). In cases
> >>where you use templates, you can also get away with copy and paste
> >>and replace "int" with "double".
> >[...]
> >
> >Ranges in D will be nowhere as convenient as they are today without
> >templates. When you write your own components, you basically have to
> >use templates in order to not incur unacceptable overhead (or impose
> >arbitrary limitations on usage -- such as requiring something to be
> >derived from some chosen base class).
> >
> >
> >T
>
> True, true. The fact that the compiler can check for the right types
> is great.
>
> Btw, the quote you have in this post:
>
> Never ascribe to malice that which is adequately explained by
> incompetence. -- Napoleon Bonaparte
>
> I'm surprised that Napoleon would say something like this. Malice is
> often a characteristic of the incompetent. The only way to get the
> better of their betters. :-)
I'm not sure if that attribution is accurate. Nick has pointed out to me
that he knows the same quote attributed to someone else, so this may be
a case of internet misattribution (I picked up that quote from somewhere
online, way back when -- no idea if the source was reliable, y'know,
being the internet and everything).
T
--
I am not young enough to know everything. -- Oscar Wilde
More information about the Digitalmars-d-learn
mailing list