On 11/30/2011 08:32 PM, Abrahm wrote:
"Jesse Phillips"<jessekphillip...@gmail.com> wrote in message
news:jb6qfv$1kut$1...@digitalmars.com...
What bearophile was referring to was the use of templates is common.
Are you sure about that? What say you Bear?
D's
templates have the advantage of being easier on the eyes and more
powerful (with the inclusion of 'static if' in the language).
Having "come from" C++land, and knowing what some people do with it,
making it EASIER to apply templates does not seem necessarily a good
thing to me. (Ref: template metaprogramming). That said, does your
statement above about D's template machinery being "powerful" etc., mean
"it's easier to do template metaprogramming in D"? If so, I, personally,
do not find that any asset at all (though I know some surely will, for
there have been books written on that "abhorrence").
Most of the argument for template metaprogramming being a bad thing in
C++ are just flat not valid in D. That is not by chance. While designing
the D template system they (including the guy who wrote one of these
books you mention) took as look at what people actually want to do with
all that abhorrence and provided a sane way to do it. With one 10th the
complexity, D can do 10 times as much.
As a specific example, one of the most abhorrent bits of D template code
I've worked with is a compile time parser generate that, at compile
time, parses a string into an AST describing the grammar that it will
then generate a recursive decent parser to parse. All in under 1-2kLOC.
Version 2 was going to include the ability to automatically reactor out
left recursion so that it could handle the D grammar as documented. Even
at the level of complexity, it wasn't really that hard to comprehend.
The same end effect is available in C++ but takes a megabyte and a half
of header files.