digitalmars.D.bugs - mixin scope/overload
- Ant <duitoolkit yahoo.ca> Jun 12 2004
- J Anderson <REMOVEanderson badmama.com.au> Jun 16 2004
- Ant <Ant_member pathlink.com> Jun 16 2004
- J Anderson <REMOVEanderson badmama.com.au> Jun 16 2004
- Ant <duitoolkit yahoo.ca> Jun 16 2004
Is this a bug or not how it's suppose to be used?
according to the docs:
"mixin's body is evaluated within the scope where the mixin appears"
so I expect the example to be valid.
if method foo(int) is renamed to bar(int) compiles and runs
if the mixin is not used and the method is copied to the class
it compiles and runs.
##########
template M()
{
void foo(int i)
{
double d = i;
foo(d);
}
}
interface I
{
void foo(int i);
void foo(double d);
}
class A : I
{
mixin M;
void foo(double d)
{
printf("i = %f\n", d);
}
}
int main(char[][] args)
{
A a = new A;
a.foo(14);
return 0;
}
#########
dmd M.d -I~/dmd/src/phobos
M.d(6): cannot implicitly convert double to int
Jun 12 2004
Ant wrote:Is this a bug or not how it's suppose to be used? according to the docs: "mixin's body is evaluated within the scope where the mixin appears" so I expect the example to be valid. if method foo(int) is renamed to bar(int) compiles and runs if the mixin is not used and the method is copied to the class it compiles and runs. ########## template M() { void foo(int i) { double d = i; foo(d); } } interface I { void foo(int i); void foo(double d); } class A : I { mixin M; void foo(double d) { printf("i = %f\n", d); } } int main(char[][] args) { A a = new A; a.foo(14); return 0; } #########dmd M.d -I~/dmd/src/phobos
M.d(6): cannot implicitly convert double to int
template M() { void foo(int i) { double d = i; this.foo(d); //this line } } -- -Anderson: http://badmama.com.au/~anderson/
Jun 16 2004
In article <cap51m$2bcb$1 digitaldaemon.com>, J Anderson says...Ant wrote:########## template M() { void foo(int i) { double d = i; foo(d); } }
template M() { void foo(int i) { double d = i; this.foo(d); //this line } }
thank you. But I would call that a workaround not a definitive solution. Is this suppouse to be "fixed" or will it stay like it is now? Ant
Jun 16 2004
Ant wrote:In article <cap51m$2bcb$1 digitaldaemon.com>, J Anderson says...Ant wrote:########## template M() { void foo(int i) { double d = i; foo(d); } }
template M() { void foo(int i) { double d = i; this.foo(d); //this line } }
thank you. But I would call that a workaround not a definitive solution. Is this suppouse to be "fixed" or will it stay like it is now? Ant
scope as it says in the documentation. -- -Anderson: http://badmama.com.au/~anderson/
Jun 16 2004
On Thu, 17 Jun 2004 10:05:23 +0800, J Anderson wrote:Ant wrote:In article <cap51m$2bcb$1 digitaldaemon.com>, J Anderson says...
scope as it says in the documentation.
Can't access the outer scope? sorry, makes no sense. Besides there are examples of that on the docs. if that's how it's suppouse to be I propose that it's changed. What about when of the methods is renamed? does the scope changes with the name of the methods. This looks to me like another example of the problem with overloading. Ant PS this sounds curt in a bad way, sorry it's not my intention.
Jun 16 2004








Ant <duitoolkit yahoo.ca>