Properties: a.b.c = 3

Bill Baxter wbaxter at gmail.com
Wed Jul 29 11:11:45 PDT 2009


On Wed, Jul 29, 2009 at 10:50 AM, Andrei
Alexandrescu<SeeWebsiteForEmail at erdani.org> wrote:
> Bill Baxter wrote:
>>
>> Yeh, I don't understand how any of this has anything to do with
>> properties.  It's the same question if you ask what should
>>
>>  a.b().c = 5
>>
>>  do.  It's the same issue whether you have properties or not, and
>> needs a solution whether you have properties or not.
>
> Well the problem is that a.b().c = 5 makes it clear that there's a function
> call in the mix, so the field-like behavior is not necessarily to be
> expected.
>
> One great thing about properties is that they are mostly interchangeable
> with fields. The a.b.c = 3 problem works against that.

Maybe you were expecting it to be possible to make properties
completely indistinguishable from fields?  But that can't really be
when you can take the address of a field and not a property.  The goal
has to be removing as many differences in behavior as possible.

On the point above,  a.b.c = 5 is dicey whether b is obviously a
function call or not, if what b returns is not an lvalue.  If I think
a.b() is returning a ref and it doesn't, then I want the compiler to
tell me I'm doing something silly -- if it can determine so.
Properties or no properties.

--bb



More information about the Digitalmars-d mailing list