On the richness of C++

Edward Diener eddielee_no_spam_here at tropicsoft.com
Sat Apr 12 16:40:06 PDT 2008


Walter Bright wrote:
> Edward Diener wrote:
>> Walter Bright wrote:
>>> Kevin Bealer wrote:
>>>> I was amazed that Boost could do things like the Lambda support with 
>>>> _1 _2, etc.
>>>> Those Boost guys are geniuses.
>>>
>>> I agree, they are geniuses. But that's really what is wrong with C++, 
>>> you shouldn't have to be a genius to get advanced things done.
>>
>> Are D's templates a complete replacement in functionality for Boost's 
>> MPL ? If so could you write an article on your web site about the 
>> how's and why's of that ? I am still trying to understand D's 
>> templates based on the sparse documentation of them.
> 
> I don't really understand Boost MPL, but D's template system is 
> considerably more powerful than C++'s.

I do not know the MPL either although I understand the general concept. 
It is a C++ template metaprogramming library for manipulating types at 
compile time so that the final result of the body of a template deals in 
whatever types the template metaprogramming needs to generalize for his 
programming task.

I agree that what I currently understand of D templates looks clearer 
than the template system in C++ but I am not knowledgable enough to know 
whether it is "better", or easier to use in doing the sorts of things 
which Boost programmers accomplish.

> I agree that more documentation 
> is needed, but one can easily write a book about it.

The question is: has anyone tackled in D some of the template 
metaprogramming tasks which various Boost programmers have accomplished 
with C++ ?

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 ), function ( universal callable ), bind and/or 
lambda ( function object creation ), shared_ptr ( sharable smart 
pointer, obviously for RAII in D because of GC ), signals ( generalized 
multicast events ), multi_index ( multiple index containers ), regex 
and/or xpressive ( regular expressions ), tokenizer ( generalized 
tokening of strings ), date_time ( date/time and time intervals ) and 
many others ( the above are just my favorites but I have hardly 
explored/used all of them ) which C++ programmers find very useful. All 
of these libraries depend on template metaprogramming in C++. Can their 
equivalents just as easily be implemented and have any of them been done 
already ?

I have not looked at the D libraries, phobos and tango I believe they 
are called, so maybe I am way off base comparing the Boost libraries to 
what may already be in D. But I am trying to get an idea if D is capable 
of doing these Boost things just as easily or easier.



More information about the Digitalmars-d mailing list