Indexing access for Lists and Maps considered harmful?
Tom Hawtin
Thomas.Hawtin at Sun.COM
Tue Jun 23 06:43:28 PDT 2009
Bruce Chapman wrote:
>
> m[a] = (n[a] = x);
>
> and therefore your translation should be
>
> becomes
>
> X t = x;
> n.put(a, t);
> m.put(a, t);
> t;
It's more subtle than that in the presence of side effects. Consider:
int[] a = new int[2009];
int i = 1;
a[i++] = a[0] = i;
System.err.println(a[1]);
That prints 2, because the post increment is on the left, while
evaluation is more or less left to right (my JLS is in the other office).
Then there is boxing and conversions between primitive types, which just
makes the whole thing positively evil.
Tom
More information about the coin-dev
mailing list