Thread overview
property: feature enhancement
May 15, 2005
ehance
May 15, 2005
Uwe Salomon
May 19, 2005
Chris Sauls
May 15, 2005
From D doc:

int test()
{
Foo f;

f.data = 3;		// same as f.data(3);
return f.data + 3;	// same as return f.data() + 3;
}

So how about:

f.data += 3;   // same as f.data( f.data()+3 )
f.data -= 3;   // same as f.data( f.data()-3 )
f.data *= 3;   // same as f.data( f.data()*3 )
f.data /= 3;   // same as f.data( f.data()/3 )

>>=
<<=
..




May 15, 2005
> So how about:
>
> f.data += 3;   // same as f.data( f.data()+3 )
> f.data -= 3;   // same as f.data( f.data()-3 )
> f.data *= 3;   // same as f.data( f.data()*3 )
> f.data /= 3;   // same as f.data( f.data()/3 )

The op= operators are guaranteed to evaluate the lvalue only once. If you rewrite it the way you propose, this would not be true anymore.

Ciao
uwe
May 19, 2005
Uwe Salomon wrote:
>> f.data += 3;   // same as f.data( f.data()+3 )
>> f.data -= 3;   // same as f.data( f.data()-3 )
>> f.data *= 3;   // same as f.data( f.data()*3 )
>> f.data /= 3;   // same as f.data( f.data()/3 )
> 
> The op= operators are guaranteed to evaluate the lvalue only once. If you  rewrite it the way you propose, this would not be true anymore.

As far as I can see, (T prop(T)) is still only being called once.  Is there some case wherein the Settor (T prop(T)) needs to emulate a Gettor (T prop()), thereby causing an internal change before the operation?  If not, then I don't see how its no longer true.

-- Chris Sauls