[Issue 277] New: Named mixin operator resolution

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Wed Aug 16 02:42:44 PDT 2006


d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=277
> 
>            Summary: Named mixin operator resolution
>            Product: D
>            Version: 0.163
>           Platform: PC
>         OS/Version: Windows
>             Status: NEW
>           Severity: normal
>           Priority: P2
>          Component: DMD
>         AssignedTo: bugzilla at digitalmars.com
>         ReportedBy: xergen at hotmail.com
> 
> 
> template TestMixin(){
>     void opCall()    {
>     }
> 
>     void opCatAssign(uint val)    {
>     }
> }
> 
> class Test{
>     mixin TestMixin bar;
> 
>     void foo(){
>     //bar(); // doesn't work !?!?
>     bar.opCall(); // works
>     //bar ~= 3; // doesn't work
>     bar.opCatAssign(3); // works
>     }
> }
> 
> void main(char[][] args){
>     Test t = new Test();
>     t.bar ~= 3; // works
>     t.bar(); // works
>     t.bar.opCall(); // works
> 
>     t.foo();
> }
> 
> May seem trivial, but its actually pretty important for some friendly things im
> working on.  Mixin operators can't be called from within the scope using the
> mixin? Odd :) Thanks.
> PS. You're my hero Walter.
> 
> 

Not sure if it will be an useful workaround but using "this" works:
----
class Test{
   mixin TestMixin bar;

   void foo(){
     this.bar(); // works
     bar.opCall();
     this.bar ~= 3; // works
     bar.opCatAssign(3);
   }
}

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d-bugs mailing list