digitalmars.D.bugs - Is this (or should it be) a bug?
- Nick (5/14) Jul 06 2005 But is it reasonable to expect it to work? Should assigning a value to a...
- Jarrett Billingsley (8/18) Jul 06 2005 I think you have to first assign a struct to the array element, i.e.
- Russ Lewis (6/23) Jul 06 2005 I agree with you that assigning a value to a struct member should add
- Nick (13/18) Jul 08 2005 I think allowing both assigning to variables and to properties should be...
- Victor Nakoryakov (7/28) Jul 06 2005 As I know only opIndexAssign inserts new element if it does not exists
The following currently does not work (gives an ArrayBoundsError.)struct A { int i; } void main() { A[int] a; a[10].i = 20; }But is it reasonable to expect it to work? Should assigning a value to a struct member be enough to consider the struct an rvalue, thus adding it to the AA? What about calling struct members? Nick
Jul 06 2005
"Nick" <Nick_member pathlink.com> wrote in message news:dagso2$2dkb$1 digitaldaemon.com...The following currently does not work (gives an ArrayBoundsError.)I think you have to first assign a struct to the array element, i.e. A[int] a; A anA; a[10]=anA; a[10].i=20; This works.struct A { int i; } void main() { A[int] a; a[10].i = 20; }
Jul 06 2005
Nick wrote:The following currently does not work (gives an ArrayBoundsError.)I agree with you that assigning a value to a struct member should add the struct to the AA, however I'm skeptical about allowing somebody to call a member function. The trouble, of course, is that your think, which looks like an assignment, might actually be calling a property. Hmmm....struct A { int i; } void main() { A[int] a; a[10].i = 20; }But is it reasonable to expect it to work? Should assigning a value to a struct member be enough to consider the struct an rvalue, thus adding it to the AA? What about calling struct members?
Jul 06 2005
In article <dah2pj$2ifp$1 digitaldaemon.com>, Russ Lewis says...I agree with you that assigning a value to a struct member should add the struct to the AA, however I'm skeptical about allowing somebody to call a member function. The trouble, of course, is that your think, which looks like an assignment, might actually be calling a property. Hmmm....I think allowing both assigning to variables and to properties should be enough to consider the struct an rvalue. Compare it to arrays, the following runs without error: but I currently cannot make my own structs work in the same way. Both assignments fail for a custom struct with length and opCatAssign. Nick
Jul 08 2005
Nick wrote:The following currently does not work (gives an ArrayBoundsError.)As I know only opIndexAssign inserts new element if it does not exists yet, but not opIndex. In your snipet opIndex was called. -- Victor (aka nail) Nakoryakov nail-mail<at>mail<dot>ru Krasnoznamensk, Moscow, Russiastruct A { int i; } void main() { A[int] a; a[10].i = 20; }But is it reasonable to expect it to work? Should assigning a value to a struct member be enough to consider the struct an rvalue, thus adding it to the AA? What about calling struct members? Nick
Jul 06 2005