@property needed or not needed?

Jacob Carlborg doob at me.com
Mon Jan 28 12:00:41 PST 2013


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

> I think Jacob's point is that a = b = c would lower to:
>
> b = c;
> a = b;

This is how the semantics should be. This also shows a clear complete 
example:

http://forum.dlang.org/thread/uxhgbxdsselokcdkvltx@forum.dlang.org?page=14#post-ke6l44:242mfh:241:40digitalmars.com

> 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.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list