Hello Travis,
BCS wrote:
Hello Travis,
Is this a bug or a "feature"?
IIRC it's a fature. I forget where, but I recall reading that they
don't overload.
I know they don't, I am just wondering why. Is it a side
effect/oversight of the implementation (misfeature), something that is
suppose to work (bug) or is there a concrete reason why (feature).
By don't overload, I'm taking about "defined to not overload".
That removes "bug" leaving "misfeature", and "feature".
I think the rational is that allowing them to overload makes the order of
expansion hard to impossible to work out.
For example:
template Bar(T) { const bool v = true; }
template Foo(T)
{
static if(Bar!(T).v)
template Bar(U : T) { const bool v = false; }
else
template Bar(U : T) { const bool v = true; }
}
mixin Foo!(int);
static assert(Bar!(char)); // works
static assert(Bar!(int)); // what about this?
By making mixins not overload, many (if not all) such cases become illegal.