Super-dee-duper D features
Hasan Aljudy
hasan.aljudy at gmail.com
Tue Feb 13 16:46:02 PST 2007
Don Clugston wrote:
> Sean Kelly wrote:
>> Walter Bright wrote:
>>> 8) I've never been able to create usable C++ templates. Notice that
>>> the DMD front end (in C++) doesn't use a single template. I know how
>>> they work (in intimate detail) but I still can't use them.
>>
>> I have no problem with C++ templates, but the syntax is such that I
>> don't consider them appropriate for a lot of the uses to which they're
>> being put. Also, in many ways, C++ templates feel like a hack. The
>> need to sprinkle such code with "template" and "typename" qualifiers
>> just so the compiler knows what it's parsing sends up a huge red flag
>> that something is wrong.
>>
>>> 9) But I see what C++ templates can do. So to me, the problem is to
>>> design templates in such a way that they are as simple to write as
>>> ordinary functions. *Then*, what templates can do can be accessible
>>> and maintainable. It's like cars - they used to be very difficult to
>>> drive, but now anyone can hop in, turn the key, and go.
>>
>> Yup. It may be that the D community is more technically adept than
>> the C++ community on average simply because of the type of people new
>> languages tend to attract, but I've seen a lot of interesting template
>> code around here.
>
> I'm certain that it's just easier in D. I'm a bit amused by the ninja
> reference to myself, since I've never done anything very sophisticated
> with C++ templates. Andrei on the other hand...
>
> My feeling is, that 'static if' instead of specialisation removes 60% of
> the mystery from template metaprogramming. Tuples remove another chunk.
> I think that if basic uses of recursion could be replaced with iteration
> and compile-time variables (even if they were mutable only inside
> foreach), it would become readable to average joe.
Yeah, a static foreach and a static while would pretty remove a lot of
the remaining mystery.
More information about the Digitalmars-d
mailing list