Worse is better?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 14 01:27:56 PDT 2014


On 10/14/2014 1:00 AM, Dicebot wrote:
> Templates are not about low level or high level of domain. It is a tool to
> reduce code redundancy and simplify maintenance of large code base. I am not
> even speaking about algorithms in STL or std.algorithm sense but much more
> routine things - common small snippets that either get copy-pasted or hidden
> behind C macros.

I discovered something very interesting about templates when writing Warp. 
Templates make it easy for unittests to test a function, by accepting dummy 
input that is conveniently of another type (such as using an array of data 
instead of an input range).

I'm sure I've heard of this before, type mocking and all, but it didn't sink in 
until I wrote Warp.


More information about the Digitalmars-d mailing list