mixin template question
Paul D Anderson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 11 20:51:02 PDT 2015
I don't understand why the following code compiles and runs
without an error:
import std.stdio;
mixin template ABC(){
int abc() { return 3; }
}
mixin ABC;
int abc() { return 4; }
void main()
{
writefln("abc() = %s", abc());
}
Doesn't the mixin ABC create a function with the same signature
as the "actual function" abc()?
It compiles with both included and writes "abc() = 4". If I
comment out the actual function then it writes "abc() = 3". The
actual function takes precedence, but why don't they conflict?
Paul
More information about the Digitalmars-d-learn
mailing list