Nobody understands templates?

Steve Teale steve.teale at britseyeview.com
Sun Mar 2 10:59:22 PST 2014


On Sunday, 2 March 2014 at 15:23:03 UTC, H. S. Teoh wrote:
> This is a pretty good primer to templates:
>
> 	https://semitwist.com/articles/article/view/template-primer-in-d
>
>
>
The trouble is with most of these tutorials that they offer 
examples that are things you would probably never want to do. I 
can already add an int to an int, or a double to a double, or an 
int to a double.

Perhaps the examples should pick on something like vector 
operations, but then who would be doing those with int, or some 
class? It would be doubles or pairs of, as in struct Coord.

I believe readers would study documentation and examples much 
more carefully if they were things they might realistically want 
to do. And that won't be type conversion - std.conv already does 
a pretty good job on that. So what?

We could really do with a place where template savvy open source 
contributors could publish interesting examples of template use.

Otherwise, Joe Soap, like me, can spend a great deal of time and 
effort in:

a) Determining when the use of a template might be advantageous,
b) Hacking at test programs to determine what the documentation 
means, and what works, and what doesn't.
c) After that, deciding whether it would be just as effective to 
use two or three separate methods.

Steve


Steve


More information about the Digitalmars-d-learn mailing list