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

Reply via email to