How to do Generic Programming in D?

Nick Sabalausky a at a.a
Tue Feb 22 14:23:53 PST 2011


"Nick Sabalausky" <a at a.a> wrote in message 
news:ik14sh$2lfi$1 at digitalmars.com...
> "Nick" <nick at example.com> wrote in message 
> news:ik11ot$2fms$1 at digitalmars.com...
>> 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.
>

Oh, and also "alias this" which, as explained in Andrei's book "The D 
Programming Language" can be a very useful alternative to MI, particularly 
when combined with nested classes. "alias this" is also good for subtyping 
structs, even though structs still aren't polymorphic.

Like Jason said, if you have specific examples of idioms, we can translate 
to D for you.




More information about the Digitalmars-d mailing list