I've just fixed UFCS for the experimental type function branch

Paul Backus snarwin at gmail.com
Fri Sep 11 01:07:55 UTC 2020

On Thursday, 10 September 2020 at 23:44:30 UTC, Bruce Carneal 
> Yes.  Of course in theory D templates are no more powerful than 
> C++ templates but anyone who has used both understands that 
> simplicity in practical use trumps theoretical equivalence.  As 
> you note, it's not even close.
> It seems to me from forum postings and reports on the 
> (un)maintainability and instability of large template heavy 
> dlang code bases, that we're approaching the practical limits 
> of our template capability.  At least we're approaching the 
> "heroic efforts may be needed ongoing" threshold.

I think the main difficulty of scaling code bases the rely 
heavily on templates (either D or C++), as compared to other 
kinds of generic code like OOP-style polymorphism or 
traits/typeclasses à la Rust and Haskell, is that templates 
themselves--not the code they generate when you instantiate them, 
but the actual *templates*--are essentially dynamically typed. In 
general, there's no way to catch errors in a template until you 
"run" it (that is, instantiate it) and see what it does.

What this suggests to me (and this is borne out by my experience) 
is that writing correct, maintainable template code probably 
requires the same kind of disciplined approach to testing as 
writing correct, maintainable code in a dynamic language like 
Python or Ruby. Don't assume anything works until you can 
demonstrate it, actively look for ways to make your code fail, 
etc. If your test suite is shorter than your template code, 
you're almost certainly not being thorough enough.

More information about the Digitalmars-d mailing list