struct inheritance, L-value return

Regan Heath regan at netwin.co.nz
Tue Jun 13 14:56:49 PDT 2006


On Tue, 13 Jun 2006 18:56:23 +0200, Oskar Linde  
<oskar.lindeREM at OVEgmail.com> wrote:
> 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];

point pt = *arr[6];

should work.

Regan




More information about the Digitalmars-d mailing list