@property needed or not needed?

Maxim Fomin maxim at maxim-fomin.ru
Mon Jan 28 09:14:17 PST 2013


On Monday, 28 January 2013 at 16:55:40 UTC, Dicebot wrote:
> On Monday, 28 January 2013 at 16:50:37 UTC, Maxim Fomin wrote:
>> Than value of this expression (note, that evaluated expression 
>> is not b, it is b = c) is assigned to a.
>
> Quoting you (that was exactly part of standard I was referring 
> too):
> "assignment expression has the value of the left operand"
>
> Left operand for (b = c) is b. Thus (b = c) has value of b. 
> Value of b is b.getter(). Thus compiler is re-writing it wrong 
> if we copy C rules.

You are mixing value of expression and expression itself. If 
assignment expression has value of right operand, it does not 
mean that in complex assignment like a = b = c , right part of 
second assignment disappears and it becomes a = b. It is still a 
= b = c , and a is assigned to value of the whole expression b = 
c, not just value of b. This means it is a.setter((b = c)) = > 
a.setter(b.setter(c.getter)). Note, that original program does 
exactly what is required by ISO C.

>> b.setter cannot be called prior to b.getter as in your example 
>> #1 due to sequence rules. The example #2 would be for 
>> expression a = c, b = c which is not a = b = c in the presence 
>> of properties.
>
> What sequence rules are you speaking about?

About that side effects are sequenced after evaluation, but it is 
actually irrelevant, because b.getter is not called.


More information about the Digitalmars-d mailing list