Template constraints in D

Lutger lutger.blijdestijn at gmail.com
Sun Jun 22 04:43:21 PDT 2008


Walter Bright wrote:

> Lutger wrote:
>> Very much so, brilliant! But what about concept maps, the suggestion is
>> to use proxy objects but won't that be very cumbersome? Aren't concept
>> maps important enough?
> 
> I think I understand concept maps, but I don't understand what the
> compelling use case for their existence is.

In C++ or possibly in D? 

In this talk - probably posted before - Douglas Gregor also talks about the
uses for concept maps, about ten minutes from 36.00 or so:
http://www.youtube.com/watch?v=Ot4WdHAGSGo

>From that talk, as far as I could understand, I think these were the most
important aspects:
- concept maps are needed to implement the C++ equivalent of D's opApply
operator. 
- they replace the existing ways to define new iterators
- map the interface of built-in types to concepts
- concept maps make it possible to define partial ordering rules between
existing types that you cannot alter. This is not relevant in D right?

In general, because concept maps can be used with existing types, they allow
for backwards compatibility and increased functionality of existing code. 

Template constraints make it possible (or much easier) to extend existing
templates via overloading, concept maps complete this extensibility in the
case both the type and the template exist and are compatible by concept but
not syntax, D. Gregor calls this 'syntax remapping'.

Whether this is compelling *for D* I don't know.



 



More information about the Digitalmars-d mailing list