Properties: a.b.c = 3

Nick Sabalausky a at a.a
Tue Jul 28 21:02:18 PDT 2009


"Daniel Keep" <daniel.keep.lists at gmail.com> wrote in message 
news:h4og1p$b3f$1 at digitalmars.com...
>
> Walter Bright wrote:
>> The issue is what if b is a property, returns a temporary object, and
>> that temp's .c field is uselessly set to 3?
>>
>> It's a classic problem with properties that are implemented as functions.
>>
>> I don't see how C#'s special property syntax adds any value for dealing
>> with this.
>>
>> One thought I had was to simply disallow the '.' to appear after a
>> function style property.
>
> Maybe the compiler could rewrite the above as:
>
> auto t = a.b;
> t.c = 3;
> a.b = t;
>
> Unless it can prove it doesn't need to.  Same solution as to the op=
> conundrum.

That's how I've always felt about it. I don't think any other approach 
really makes any sense. 





More information about the Digitalmars-d mailing list