Variants and pattern matching implementation

David B. Held dheld at codelogicconsulting.com
Sun May 13 11:21:12 PDT 2007


Reiner Pope wrote:
> [...]
> That's all that comes to mind now. Are there any thoughts about 
> implementing some kind of concepts/checking for template parameters? I'm 
> especially uncertain of nested tuples and value parameters, which both 
> currently (and a lot more) are all hidden behind the single
> 
>> template Foo(T...)
> 
> idiom.

Well, concepts are just a special form of metatypes, which is what I am 
interested in more generally.  I actually argued for metatypes several 
years ago, from my headaches working with C++, and believing there had 
to be A Better Way.  The C++ Concepts proposal proves that lots of other 
people have come to the same conclusion.

However, Concepts are designed primarily to support structural 
metatypes, which makes sense and is useful, but is by no means complete. 
  D has an opportunity to get metatyping correct without having to bolt 
it on as an afterthought, like Concepts.  However, the need for 
metatypes must be motivated by real-world examples, and since 
metaprogramming is considerably less frequent than muggleprogramming, 
it's harder to convince the Unbelievers.

Interestingly enough, Andrei is one of the Unbelievers that thinks the 
problems solved by metatyping can be addressed satisfactorily without 
first-class metatypes, and even Walter tends to think that 
specialization is Good Enough.  So it's an uphill battle for me to 
champion first-class metatypes, but having examples that don't just come 
from my own experience definitely helps.  Consider that an Open Call to 
the D community at large to bring forward more examples like yours 
(which is great, BTW...thanks for shaing).

Dave



More information about the Digitalmars-d mailing list