[Issue 11218] New: alias this and mixin templates should be interchangeable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 10 10:36:36 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11218
Summary: alias this and mixin templates should be
interchangeable
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: eberhardhoepfner at gmx.de
--- Comment #0 from Eberhard <eberhardhoepfner at gmx.de> 2013-10-10 10:36:35 PDT ---
mixin templates and alias-this are really the same thing, the first being a
static mixin, the second a dynamic mixin. So I expect them to be
interchangeable:
import std.stdio;
mixin template T() {
void foo() { writeln("mixin"); }
}
class C {
void foo() { writeln("mixin"); }
}
class Outer {
void foo() { writeln("outer"); }
class Inner {
static const bool TEMPLATE = true;
static if (TEMPLATE) {
mixin T;
} else {
C c = new C;
alias c this;
}
void test() {
foo();
}
}
void test() {
Inner i = new Inner;
i.test();
}
}
void main(string[] args) {
Outer o = new Outer;
o.test();
}
Output:
TEMPLATE == true: "mixin"
TEMPLATE == false: "outer" <-- should be "mixin"!
I expect alias-this to behave like a mixin template:
class C {
void foo() {}
}
class Outer {
void foo() {}
static class Inner {
C c = new C;
alias c this;
void test() {
foo(); // Error
}
}
}
test.d(10): Error: this for foo needs to be type Outer not type
test.Outer.Inner
--
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