[Issue 8074] template-mixin example contradicts text

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 14 09:01:37 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=8074



--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> 2013-02-14 09:01:34 PST ---
I think there is no ambiguity for current behavior.

I can explain it based on the 'overload set resolution rule'.

Please regard these mixin declarations as two import statements.

  mixin Foo;
  mixin Bar;
  void main() { func(); }

Can be considered to:

  import foo;
  import bar;
  void main() { func(); }

And each module contains following declarations.

  module foo;  // ---
  int x = 5;
  void func(int x) { writeln("Foo.func(), x = ", x); }

  module bar;  // ---
  int x = 4;
  void func() { writeln("Bar.func(), x = ", x); }

Finally, the 'func()' is resolved to the call of bar.func.

"compiler will resolve an ambiguous mixin-ed symbol by regarding it as overload
set.." - This is much reasonable and consistent rule. If 'foo' is called with
some arguments but cannot eliminate the ambiguity, it will be error. Otherwise
simply will succeed to call.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list