[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Would you consider this a bug?
David Kastrup <firstname.lastname@example.org> writes:
>a[[2,1,0]] = a
>a will be set to [3,4,3]
>One has to write
>a[[2,1,0]] = a + 0
>in order to get the more correct seeming [5,4,3].
>Would you think this a bug?
The same correct results could also be obtained with the statement
a[[2,1,0]] = a[[0,1,2]]
I certainly would consider this a bug. I think I can understand how it comes
about, though. Evidently the contents of A are being updated directly as it
loops through the expression on the right side of the equation. On the other
hand, if one puts A+0 on the right side of the equation, it generates a
temporary array to store the results before placing them in the correct places
on the left side of the equation, so the left side doesn't get changed midway
in the process.
The solution would be that
1. If the variable on the left is indexed, AND
2. The same variable is on the right, THEN
3. Store the expression on the right in a temporary array.