On the richness of C++

Jason House jason.james.house at gmail.com
Tue Apr 15 12:38:00 PDT 2008


Walter Bright Wrote:

> Edward Diener wrote:
> > The question is: has anyone tackled in D some of the template 
> > metaprogramming tasks which various Boost programmers have accomplished 
> > with C++ ?
> 
> Yes. See std.algorithms, for one. It is written by Andrei Alexandrescu, 
> the guy who revolutionized template programming in C++ with his book 
> "Modern C++ Design."
> [...]
> For one example, I reduced a whole chapter of Andrei's "Modern C++ 
> Design" to one page of D, see std.typetuple.


I'd love to see some kind of page comparing D with the contents of Modern C++ Design.  It'd be a good selling point for D when the hoards of disgruntled C++ programmers start looking at D.  I wonder what could be done within copy right restrictions...



> > I am trying to get a feel for how different, or how much easier ( or 
> > perhaps harder ) it would be to do Boost things like Spirit ( 
> > lex/yacc-like DSEL ),
> 
> I wrote a toy Spirit clone a while back, just as a proof of concept. It 
> is very doable.


Would you be willing to add it on dsource, scrapple, etc...?  I think the doost project has been inactive for a while...



> > function ( universal callable ), bind and/or 
> > lambda ( function object creation ),
> 
> I believe that closures and delegates make those irrelevant.


Unfortunately not.

Function collapses *all* the various function types into one easy to use form.  D has both function and delegate, so some 3rd party utility is still needed.

Closures capture variables by reference.  This means that creating delegates inside a foreach loop (with deferred evaluation) could fail to have the expected behavior.  Bind stores stuff by value, so I still find myself using bind libraries.



More information about the Digitalmars-d mailing list