Dinamic operator binding Proposal

JDavidLS jdavidls at gmail.com
Fri Sep 21 21:01:00 PDT 2007


Class Obj
{
  uint a,b;

  Str possibleOpCall1(uint x, uint y){a += y; b -=x;}

  Str possibleOpCall2(uint x, uint y){a -= x; b += y;}

  Str delegate(uint, uint) opCall = &possibleOpCall1;

  void changeMode()
  {
    opCall = &opssibleOpCall2;
  }
}

¿¿dinamic operator bindigis facible on structs??

struct Blk
{
  uint a,b;
  Str function(uint, uint) opCall = &possibleOpCall1;
  static Str possibleOpCall1(ref Blk blk, uint x, uint y)
  {
    blk.a += y; 
    blk.b -=x; 
  }
  ...
}






More information about the Digitalmars-d mailing list