digitalmars.D.learn - opDispatch with implicit receiver
- Jacob Carlborg (17/17) Aug 23 2012 Is it supposed to be possible to use opDispatch with an implicit
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (7/22) Aug 23 2012 I don't know the actual decision that has been made at the time but I am...
- Jacob Carlborg (4/9) Aug 23 2012 I see.
Is it supposed to be possible to use opDispatch with an implicit 
receiver? For example:
class Foo
{
     this ()
     {
         foo(3);
     }
     void opDispatch (string name) (int value) {}
}
The above code will fail to compile with the following message:
Error: undefined identifier foo, did you mean class Foo?
If I prepend the call to "foo" with an explicit receiver, i.e. 
"this.foo(3);" the it compiles without errors.
DMD 2.060.
-- 
/Jacob Carlborg
 Aug 23 2012
On 08/23/2012 08:30 AM, Jacob Carlborg wrote:
 Is it supposed to be possible to use opDispatch with an implicit
 receiver? For example:
 class Foo
 {
 this ()
 {
 foo(3);
 }
 void opDispatch (string name) (int value) {}
 }
 The above code will fail to compile with the following message:
 Error: undefined identifier foo, did you mean class Foo?
 If I prepend the call to "foo" with an explicit receiver, i.e.
 "this.foo(3);" the it compiles without errors.
 DMD 2.060.
I don't know the actual decision that has been made at the time but I am 
happy that it works this way. Otherwise the compiler would not be able 
to flag silly typos in classes that define opDispatch. Yes, it is still 
possible to make typos after the 'this.' part but at least it is 
explicit this way.
Ali
 Aug 23 2012
On 2012-08-23 17:35, Ali Çehreli wrote:I don't know the actual decision that has been made at the time but I am happy that it works this way. Otherwise the compiler would not be able to flag silly typos in classes that define opDispatch. Yes, it is still possible to make typos after the 'this.' part but at least it is explicit this way.I see. -- /Jacob Carlborg
 Aug 23 2012








 
  
  
  Jacob Carlborg <doob me.com>
 Jacob Carlborg <doob me.com>