DIP23 draft: Fixing properties redux

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Feb 3 11:42:17 PST 2013


On 2/3/13 11:34 AM, Johannes Pfau wrote:
> You have to consider cases though where you have both a setter and a
> getter returning a 'ref value'.
>
> @property ref int value();
> @property void value(int new);

For now I disallow 0-parameter top level properties. This is a good 
argument for keeping things that way.

> * Is it valid to define both at the same time?
> * Which one is used for assignment etc?
>
>>> * Is taking ref values in the setter OK?
>>
>> How do you mean that?
>
> @property int value(ref int new);
>
> IIRC that was just meant to complement the "is returning ref OK".
> Usually nothing bad can happen. Although the ref parameter could be
> converted into a pointer with some nasty tricks it's probably not the
> job of the language to prevent that.

Yah, there should be no restrictions there.


Andrei



More information about the Digitalmars-d mailing list