in reply to Re^5: list assignment and undef
in thread list assignment and undef
In each case I use (1..2). Is it a different list each time?
What I called caching is actually constant flattening. That means each op instance is independent.
You only visit each element of each flattened list once. So if you had changed it, you would never know.
The bug is that the "constants" of the list into which 1..2 is flattened aren't marked as read-only.
Except "for constant .. constant" is optimised to not flatten the list. And with this, my question is answerd.
>perl -le"for (1..2) { print $_++ for 1..2 }" 1 2 1 2 # Disables the "for constant .. constant" optimisation >perl -le"for (1..2) { print $_++ for (),1..2 }" 1 2 2 3 >perl -le"for (1..2) { map print($_++), 1..2 }" 1 2 2 3
|
|---|