-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistency in assignment: Numbers vs. Arrays #7861
Comments
This is definitely intended. You will have to take a copy ( |
This is entirely on purpose. |
Is it not possible to mimic GNU Octave COW? |
Absolutely – just copy your array before modifying it ;-) |
Copying manually isn't the smartest solution. |
I would argue that's it's the most explicit and forces the programmer to think about if she really wants to assign the same reference object to two variables or if she wants two separate reference objects. No magic behind the back. |
Currently our arrays are true mutable arrays. We might have immutable arrays as well in the future. |
See #5556 for a discussion on copy-on-write semantics. |
You can also search old julia-dev discussions about copy-on-write. Bottom line is that many of us would view it as harmful. How do you implement |
I don't know if this is the intended behavior, could you please clarify?
In GNU Octave, A and B point to the same address location as long as no write operation is performed. The expression
A[1,1] = 0
tells to the language that it is time to copy the underlying data and make A and B two distinct objects.The text was updated successfully, but these errors were encountered: