opIndexAddAssign? ...

Manfred Nowak svv1999 at hotmail.com
Fri Feb 9 08:54:46 PST 2007


"Jarrett Billingsley" <kb3ctd2 at yahoo.com> wrote
> How, for example would you do something as simple as
> this: 
> 
> void opIndexAssign(int value, int key)
> {
>     mData[key] = value % 10;
> }
> 
> using inout return values?

The question is: what do really want to do and why do you have to mix 
up your intentions?

Your intention seems to bind an operation to the valuetype of the AA. 
But you have bound it to the AA directly and not to the valuetype.

The code
  instance[ key]= value;
should be called approximately as
  instance.opIndex_l(key)= typeof( mData[key]).opAssign( value)

In fact your example is not that easy because it is unclear what the 
return value of opIndex( int) would be:
  mData[key]
or
  mData[key] * 10
or void as your opIndexAssign suggests?

-manfred
  



More information about the Digitalmars-d mailing list