Properties: a.b.c = 3

KennyTM~ kennytm at gmail.com
Wed Jul 29 02:49:22 PDT 2009


Lionello Lunesu wrote:
> 
> "Ary Borenszweig" <ary at esperanto.org.ar> wrote in message 
> news:h4ocm1$28k$1 at digitalmars.com...
>> Walter Bright escribió:
>>> 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 only if the return value of the property is a struct? For class 
>> references it'll work well (except your property returns a new object 
>> each time, which is kind of a weird way to implement a property).
> 
> What if structure B has get/set c and B.c(int) does something non-local? 
> Then the function call ("property assignment") should be allowed.
> 
> L.

No, you should tell the author of struct B to revise the design :p



More information about the Digitalmars-d mailing list