@property needed or not needed?
Maxim Fomin
maxim at maxim-fomin.ru
Mon Jan 28 07:05:20 PST 2013
On Monday, 28 January 2013 at 14:38:19 UTC, Dicebot wrote:
> On Monday, 28 January 2013 at 14:28:30 UTC, Maxim Fomin wrote:
>> On Monday, 28 January 2013 at 14:09:20 UTC, Dicebot wrote:
>>> On Monday, 28 January 2013 at 14:00:16 UTC, Maxim Fomin wrote:
>>>> Returning void instead of int in the example break
>>>> assignment chaining a = b = c. Besides, how such implicitly
>>>> defined functions may call user defined code (check input
>>>> validity, call events, etc.)?
>>>
>>> It should not if evaluating the value of (b = c) will call
>>> getter for b.
>>
>> Why getter and not setter? Expression a = b = c = d should
>> call getter for d and setter for rest of them. And if c setter
>> returns void the chain breaks.
>
> "a = b" calls setter
Agree.
> "(a = b)" calls setter first, getter second
How it can call setter for a if b is not evaluated? This
expression is rewritten to setter function call with argument
that getter provides.
> "x = b = c" is same as "x = (b = c)" thus calls setter, then
> getter and then setter again
It should be rewritten to a.setter(b.setter(c.getter()))
> I don't know how it is done know, but that is quite logical
> C-like approach based on the fact that result of expression (a
> = b) is equal to a.
Yes, that is why if setter for "a" defaults to void and not to
typeof(b) assignment chaining is broken.
More information about the Digitalmars-d
mailing list