On the richness of C++
Edward Diener
eddielee_no_spam_here at tropicsoft.com
Tue Apr 15 18:28:57 PDT 2008
Walter Bright wrote:
> 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.
It is only a big deal in the sense that proving a single callback
signature or a single event signature, rather than two of each because
of the presumed need to support both delegates and function pointers, is
a big deal. In other words it is much cleaner to present a single
callable interface in a language, ala boost::function, Python callables,
C# delegates etc etc. The callback or event does not care if the
callable is a delegate or function pointer as long as the signature
matches, so it is a PITA if a language can not fold both into a single
callable concept. That is the issue and I think if you think about it
you will realize why it is better from both a clarity and ease of use
perspective to have a single callable representing both. There is no
sense in a language as rich as D to have to move backward from what
other other good languages are able to represent.
More information about the Digitalmars-d
mailing list