post/pre-increment/decrement and property

Jacob Carlborg doob at me.com
Tue Feb 7 23:18:59 PST 2012


On 2012-02-08 01:50, Robert Clipsham wrote:
> On 07/02/2012 23:04, Timon Gehr wrote:
>>> Try this:
>>> ----
>>> int _foo;
>>> @property ref foo() {
>>> return _foo;
>>> }
>>> @property ref foo(int foo) {
>>> return _foo = foo;
>>> }
>>> void main() {
>>> ++foo;
>>> }
>>> ----
>>>
>>> Using 'ref' instead of auto returns a reference to _foo, allowing it to
>>> be modified.
>>>
>>
>> Yes, but then he cannot verify the new value.
>
> So what's actually being asked is can the following happen then?
>
> ++foo;
>
> becomes:
>
> foo(foo + 1);

Yes, we need some form of property rewrite. Wasn't someone working on that?

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list