About the difference between bindings and modifying mutable objects, there were many questions about it here in this forum, I selected some of my previous answers:
I did not find the specific section of the manual that explains this, so I will try to explain it myself (but I am almost sure such section exists).
The problem I see is that your mental model on how variables and objects work is not how they work in Julia (but I am sure in other languages you would see the behavior you did expect).
In Julia, a variable is just a name for some value in some scope. When you attribute a value to some variable you are never copying it, you are binding it, this is…
A wise decision.
In practice things happens as you describe, but there is also a fundamental misunderstanding here: copy is blind to the inner elements, it does not take different decisions based on the type of the inner elements, it always do the same thing: copying a reference to the element.
“But what about Ints”, you may say, “they are copied by value” or yet, “changes I make to them do not reflect in the original array”. To that I have two answers:
“changes I make to them do not refle…
1 Like