[Issue 1182] New: Mixins scope
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 24 01:27:33 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1182
Summary: Mixins scope
Product: D
Version: 1.013
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: aarti at interia.pl
Spec: Mixin Scope
The declarations in a mixin are 'imported' into the surrounding scope. If the
name of a declaration in a mixin is the same as a declaration in the
surrounding scope, the surrounding declaration overrides the mixin one.
---
Mixins should not only compare name with existing symbols in current scope, but
in case of functions also parameters. It will allow proper function
overloading. Currently following test case fails to compile:
import std.stdio;
template TestTemplate(T) {
T policy(int i) { return T.init;}
int policy() { return 1; }
}
class TestClass {
mixin TestTemplate!(TestClass);
TestClass policy(int i) { return this; }
}
void main() {
writefln((new TestClass).policy);
}
---
It is quite painful limitation of mixins, and IMHO should be bug. I put it as
enhancement because it conforms literal interpretation of specs.
--
More information about the Digitalmars-d-bugs
mailing list