On 08/09/2016 03:10 PM, Engine Machine wrote:
> I try to use a mixin template and redefine some behaviors but D includes
> both and then I get ambiguity.

It's not always possible to understand without seeing actual code.

> I was sure I read somewhere that when one
> uses mixin template it won't include what is already there?
>
> mixin template X
> {
>    void foo() { }
> }
>
> struct s
> {
>    mixin template
>    void foo() { }
> }
>
> I was pretty sure I read somewhere that D would not include the foo from
> the template since it already exists.

I've come up with the following code from your description. It compiles and prints "from struct" with DMD64 D Compiler v2.071.2-b2:

import std.stdio;

mixin template X() {
    void foo() { writefln("from mixin");}
}

struct s
{
   mixin X;
    void foo() { writefln("from struct"); }
}

void main() {
    auto a = s();
    a.foo();
}

How is your code different?

Ali

Reply via email to