On Thu, Mar 12, 2009 at 9:33 AM, Andrei Alexandrescu <[email protected]> wrote: > Hello, > > > I'm looking for a catchy phrase denoting this D idiom: > > template Blah(Stuff) > { > alias ... Blah; > } > > i.e., defining inside a template a symbol of the same name as the template > itself. Then you can use Blah!(X, Y) to mean Blah!(X, Y).Blah. > > What would be a catchy, descriptive, and memorable phrase for this?
...Unnecessary? You know i have to be contrary :P but I have never found a use for multiple declarations inside a template _except_ when it's used as a mixin. Most of the time, I declare exactly one symbol inside the template, and it's always the same name as the template. Having to specify the name of the template over and over inside it is a blatant violation of DRY, easy to mess up (typos, changing the template name etc.) and is hard to diagnose when you do it wrong, since the compiler just has no idea what you're trying to do and you end up with all sorts of confusing errors about voids having no value. Allowing multiple declarations inside templates looks good in the spec, but honestly, I only ever use it for mixins. My mixin templates are also never used as anything other than mixin templates, creating this sort of split between templates and mixins, even though they're represented by the same language structure. Mixins are really more like a limited form of semihygenic AST macro, one which can only expand to declarations and not arbitrary code structures. If templates were limited to a single declaration - and mixins were either changed to a different "type" or replaced outright by macros - I'd be perfectly happy, and there'd be no need for Implicit Template Name Forwarding (do you see what I just did there ;) ).
