@property needed or not needed?

Steven Schveighoffer schveiguy at yahoo.com
Tue Jan 29 06:58:47 PST 2013


On Mon, 28 Jan 2013 15:00:41 -0500, Jacob Carlborg <doob at me.com> wrote:

> On 2013-01-28 17:21, Steven Schveighoffer wrote:

>> But I think it would be wasteful in the given case.  __a is already in
>> the register, I think actually the return __a is a noop.
>>
>> In other cases, where the property value may be a large struct or
>> whatnot, not returning the new value from a setter would make sense.
>>
>> It would be nice if the compiler made the right choice depending on
>> whether you returned a value from the property or not.
>
> Then it's up to the compiler to implement them, I don't need to know the  
> details in the optimizations it can do.

Like I said, the synthesizing of properties can be done via a library.
The compiler simply needs to call the getter when the setter returns void,
or return the setter's return value when it returns a value.

-Steve


More information about the Digitalmars-d mailing list