On Sun, Oct 2, 2011 at 04:20, bearophile <[email protected]> wrote: > This little program is a reduction of code recently shown around here: > > > template Spam(T, alias P) { enum Spam = P!T; } > template Foo(T, Preds...) { > enum bool Foo = Spam!(T, Preds[0]); > } > template Bar(T) { enum Bar = true; } > static assert(Foo!(int, Bar)); > void main() {} > > > Do you know why the P argument of Spam needs "alias" before?
Because P is a template name, not a type. 'Bar' is not a type, it's a template: a blueprint for producing code. Symbols, can only be manipulated in D through aliases (though it's cool they can be manipulated at all!) > The type tuple Preds of Foo doesn't need an "alias" before. Because template parameters tuples are mongrel constructs, able to store both types and aliases. Tuples members are automatically aliases, if you will. > Isn't it possible to remove the need to use such "alias" for template > template arguments in D? (This is a question I've had to ask since a lot of > time). That sure would simplify some code, particularly when you write generic code that deals with both types and symbols (Yes, it happens). I don't know if it's possible and/or if it's a good idea or not. Philippe
