www.digitalmars.com         C & C++   DMDScript  

D - BUG?: opIndex in opApply

reply "Lars Ivar Igesund" <larsivi stud.ntnu.no> writes:
I'm having a problem when casting an object from an opIndex
and using the resulting object as an argument to the delegate in
an opApply function.

The attached example gives the following error message:

C:\projects\code\foo>dmd foreach.d
foreach.d(25): 'cast(foobar )(this.opIndex(i))' is not an lvalue

Is this a symptom for the
"
Note: Array index overloading currently does not work for the lvalue of an
op=, ++, or -- operator.
"
comment in the docs? Everything else I've tried seems to have
worked.

Lars Ivar Igesund


begin 666 foreach.d


M"GT-" T*8VQA<W, <W5B9F]O(#H

M("  >PT*("  ("  ;RYA9&1/<E-O;65T:&EN9R I.PT*("  ('T-"B  ?0T*



M;'0 /2!D9R H9F]O8F%R*71H:7-;:5TI.PT*("  ("  :68 *')E<W5L="D 

M(')E<W5L=#L-

`
end
Nov 06 2003
parent "Walter" <walter digitalmars.com> writes:
The difficulty you're having is the parameter to dg() is an inout parameter.
That means it is passed by reference. Casting creates a conversion, which
then cannot be by reference, hence the message.

"Lars Ivar Igesund" <larsivi stud.ntnu.no> wrote in message
news:bodren$pm9$1 digitaldaemon.com...
 I'm having a problem when casting an object from an opIndex
 and using the resulting object as an argument to the delegate in
 an opApply function.

 The attached example gives the following error message:

 C:\projects\code\foo>dmd foreach.d
 foreach.d(25): 'cast(foobar )(this.opIndex(i))' is not an lvalue

 Is this a symptom for the
 "
 Note: Array index overloading currently does not work for the lvalue of an
 op=, ++, or -- operator.
 "
 comment in the docs? Everything else I've tried seems to have
 worked.

 Lars Ivar Igesund
Nov 06 2003