struct inheritance, L-value return
Oskar Linde
oskar.lindeREM at OVEgmail.com
Tue Jun 13 09:56:23 PDT 2006
Chris Nicholson-Sauls skrev:
> Oskar Linde wrote:
>> cschueler skrev:
>>> There is more missing in D that prevents me to port the
>>> system fully:
>>>
>>> - explicit return by reference (return an L-value)
>>> - struct constructors
>>>
>>> These are not showblockers, but missing them is ugly!
>>
>>
>> I agree. Those have both been discussed several times. One common
>> implication of not having l-value returns is:
>>
>> struct point { int x,y; }
>> ....
>> MyArray!(point) arr;
>> ....
>> arr[5].x = 3; // no effect
>>
>
> Write MyArray.opIndex to return a pointer and it will work. I do still
> agree with the proposal, however.
That will work in this case, but will break the rvalue case instead:
point pt = arr[6];
/Oskar
More information about the Digitalmars-d
mailing list