On 11/27/11 10:03 AM, Jacob Carlborg wrote:
For the simpler cases an interface is easier to reason about. But yes,
template constraints are more powerful.

I've reached the same conclusion. Symbolic interfaces explode quite quickly. Fortunately, the experimentation in that direction has been already done in the context of C++ concepts. We designed restricted templates as a simple method to address the same problem that C++ concepts do, and restricted templates have served D exceedingly well.

There are ways to address the issue "why did type X not satisfy constraint E on a template?" at both compiler and library level. The compiler could e.g. explain which expressions in a combination of conjunctions and disjunctions has failed. A library could define a catch-all function that issues the appropriate error message (though this is rather laborious). I personally think the compiler-based approach can be very fertile.


Andrei

Reply via email to