Properties: a.b.c = 3

Ary Borenszweig ary at esperanto.org.ar
Wed Jul 29 11:39:07 PDT 2009


Andrei Alexandrescu wrote:
> Ary Borenszweig wrote:
>> Andrei Alexandrescu wrote:
>>> Ary Borenszweig wrote:
>>>> Andrei Alexandrescu 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.
>>>>
>>>> No. Whenever you do
>>>>
>>>> Expression1 . Expression2 . Expression3 = Expression4.
>>>>
>>>> and Expression 2 is a struct type, and Expression 3 is not a static 
>>>> field of the struct, that should be an error.
>>>
>>> I don't think D allows expressions to the right of ".".
>>
>> Ok, then change the rule to
>>
>> a . b . c  = d;
>>
>> where b is an identifier or a function call, c is an identifier.
> 
> How about this fella then.
> 
> a.b[5].c = d;
> 
> Should work or not?
> 
> 
> Andrei

Not if b[5] is a struct. Do I need to list evey possible syntax there it 
to get my point clear? :-(

I'll change it to:

a.b.c = d;

If b is anything that has a struct type, and c is anything else, the 
statement must report an error.



More information about the Digitalmars-d mailing list