August 04, 2005
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>
August 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.
Top | Discussion index | About this forum | D home