Properties: a.b.c = 3
Nick Sabalausky
a at a.a
Thu Jul 30 11:46:48 PDT 2009
"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
news:op.uxv7r6ndeav7ka at localhost.localdomain...
> On Thu, 30 Jul 2009 14:09:06 -0400, Nick Sabalausky <a at a.a> wrote:
>
>> "Zhenyu Zhou" <rinick at gmail.com> wrote in message
>> news:h4rfif$2os2$1 at digitalmars.com...
>>>
>>> e.g.
>>> Rectangle rect(Rectangle r) {
>>> _rect = r;
>>> redraw();
>>> return _rect;
>>> }
>>>
>>> If you allow
>>> widget.rect.w = 200;
>>> widget.rect.h = 100;
>>> you will have to write much more code to handle the painting correctly.
>>> and we don't want to call redraw twice here
>>>
>>
>> I've dealt with that sort of thing in C# and it's a trivial issue. When
>> you
>> write code such as the above, it's very clear that you're changing the
>> rect
>> twice. If that's a problem, you just do this:
>>
>> widget.rect = Rect(200, 100);
>
> Rect has 4 values (x, y, width, height), otherwise, the example doesn't
> make much sense.
>
I've dealt with that as well, and done both of these (though not at the same
time obviously ;) ):
- widget.rect = Rect(widget.rect.x, widget.rect.y, 200, 100);
- Cache the reference manually.
So still easy.
More information about the Digitalmars-d
mailing list