Nick Wrote: > 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 don't have the book, but I'm sure that if you posted an example task, someone here (or on d.learn) would translate it using their favorite D style. > D lacks MI, classes and delegates seem heavy (allocated on heap, with > one extra pointer and new for each delegate) and has instead template > mixins which do not create types and string mixing which create... anything. Nick addressed some of these already. I thought delegates were passed like a struct on the stack. The extra pointer in a delegate seems handy to me. It's much cleaner than what C++ does. There's also C-like function pointers. You also left out "static if", compile-time function execution, and is expressions. They replace a lot of the required magic from C++. A lot of people swear by string mixins, but I use them sparingly. There's also conditional templates which I've never used, but look useful. > > So I am a bit lost. > > I guess I am looking for some code&examples to read to "get" GP in D. A > bit like "Modern C++ Programming". > > Of course, the basic question being: is D2 sufficient to support > everything that is possible in C++? > > Thanks!