On the richness of C++

Walter Bright newshound1 at digitalmars.com
Tue Apr 15 13:32:21 PDT 2008


Jason House wrote:
> 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...

If you want to write such a page, I'm sure Andrei would be willing to 
discuss it with you.


>>> 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...

I don't remember what I did with it <g>.

>>> 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.

I'm not sure that's such a big deal.


> 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.

If you expect captured variables to be by value, sure. But I always 
expected them to be by reference!



More information about the Digitalmars-d mailing list