"Nick" <[email protected]> wrote in message 
news:[email protected]...
> Coming from Andrei's work in C++ "Modern C++ Programming" I wonder how to 
> implement many of those patterns in D?
>
> In C++ I would work with type lists and use lots of multiple inheritance 
> and templates to get the magic I need.
>

I abandoned C++ about 10 years ago so I don't know anything about the 
patterns you're talking about, but:

> D lacks MI,

Replaced by either mixins or interfaces, depending on what you're trying to 
do.

> classes and delegates seem heavy (allocated on heap, with one extra 
> pointer and new for each delegate)

IIRC, non-heap-based value-semantics classes are kind of rare in C++. If you 
want a value-semantics "class" in D, you use a struct. You give up the 
ability to subclass, but I've heard there are major problems combining 
inheritence with value-semantics even in C++ anyway.

> I guess I am looking for some code&examples to read to "get" GP in D. A 
> bit like "Modern C++ Programming".
>

If by "GP" you mean generic programming, then the primary mechanisms for 
that in D are CTFE (compile-time function execution), templates and 
string/template mixins.


Reply via email to