You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pluto cannot detect if functions are mutating their input arguments (changing an array element is lowered to setindex!), therefore 2nd cell is considered only as reading array, not as writing to it.
This is both a technical (how can you reliably detect which function argument is mutated?) and conceptual problem (cell order in the notebook should not be relevant, when are you referring to the original and the mutated array?).
The solution is to pass explicitly dependency information by assigning the mutated array to a new label:
begin
array[2] = 22
modified_array = array
end
This way it is ensured that each reference to modified_array has modified_array[2] == 22.
However, array[2] is still undefined - it could contain 2 or 22.
Pluto is designed to disallow reassigning variables, but changing the values inside an array is legal. This is a little confusing.
E.g.
It seems the indexed array assignment takes precedence rather than the order of the cells for reactivity.
When the cell where
array
is first assigned is rerun, the# do stuff with array
values change to reflect the original assignment.Then, once another cell is run, these cells revert to the indexed reassignment.
The text was updated successfully, but these errors were encountered: