Properties: a.b.c = 3

Ary Borenszweig ary at esperanto.org.ar
Wed Jul 29 12:19:25 PDT 2009


Andrei Alexandrescu wrote:
> Steven Schveighoffer wrote:
>> On Wed, 29 Jul 2009 14:08:18 -0400, Andrei Alexandrescu 
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>
>>> Steven Schveighoffer wrote:
>>>> It would be nice if the compiler could help by simply rejecting what 
>>>> it can reject (assignment to rvalues), but other than that, there's 
>>>> not much that can be done.
>>>>  This can be detected in simple cases, but in the case where the end 
>>>> point is a function, it will be difficult or impossible.
>>>
>>> I think it is eminently possible, but we must figure a solution that 
>>> doesn't complicate the language all too much.
>>
>> Here is a struct, defined in a .di file:
>>
>> struct S
>> {
>>   private int _c;
>>   int c();
>>   void c(int n);
>> }
>>
>> struct S2
>> {
>>   S b();
>> }
>>
>> Now, in your main file you have:
>>
>> void main()
>> {
>>   S2 a;
>>   a.b.c = 3;
>> }
>>
>> How in the world is the compiler supposed to know whether to allow 
>> this or not?
> 
> By making a conservative decision.
> 
> Andrei

Yay! :-)



More information about the Digitalmars-d mailing list