On Wednesday, November 30, 2011 22:32:51 Abrahm wrote: > "Jesse Phillips" <[email protected]> wrote in message > news:[email protected]... > > > 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").
Andrei Alexadrescu, the author of Modern C++ (_the_ book on template metaprogramming), is one of the leaders in the D community. There is no question that D's templates are intended to be able to do powerful metaprogramming. However, much of what would be truly disgusting in C++ is incredibly simple in D such that it isn't an abhorrence at all. You don't have to constantly fight templates to be able to do anything fancy. Instead, the resulting code is much more intuitive and maintainable. However, aside from template constraints, the primary use of templates in D (at least in the standard library) is generally related to simply making functions more generic, not trying to do excessively complicated stuff. Templates in D are absolutely fantastic in comparison to C++'s templates and are a _major_ boon IMHO. http://stackoverflow.com/questions/7300298/metaprogramming-in-c-and-in-d - Jonathan M Davis
