digitalmars.D - Undocumented AA behavior
- zwang (9/9) Aug 04 2005 When a key is used in an lvalue associative array, the same key can be
- Burton Radons (5/15) Aug 04 2005 That should read "Undefined AA behavior"; a different implementation
When a key is used in an lvalue associative array, the same key can be safely used by the [] operator of a rvalue associative array without throwing an ArrayBoundsError exception at run-time. For example: <code> int k=1; int[int] m; // m: {} m[k] = m[k]*m[k]; // m: {1->0} ++m[++k]; // m: {1->0, 2->1} </code>
Aug 04 2005
zwang wrote:When a key is used in an lvalue associative array, the same key can be safely used by the [] operator of a rvalue associative array without throwing an ArrayBoundsError exception at run-time. For example: <code> int k=1; int[int] m; // m: {} m[k] = m[k]*m[k]; // m: {1->0} ++m[++k]; // m: {1->0, 2->1} </code>That should read "Undefined AA behavior"; a different implementation could throw an ArrayBoundsError on it, and could certainly legally refuse to compile the code at all. But let's not get into yet another discussion of C's undefined expression evaluation order.
Aug 04 2005