Hacker News new | ask | show | jobs
by ofrzeta 2818 days ago
This is also a gem: "Because list is already immutable there's no practical need to actually create a copy of the list-instance, therefore list and copy are the same instance. However if you copy a mutable list, copy is indeed a new instance so it's garanteed there's no side-effects when mutating the original list"

So you can get a "reference" to the same data where one reference gives you the data immutably while the other one lets you change it. Sounds like a recipe for subtle bugs.

1 comments

> where one reference gives you the data immutably while the other one lets you change it

What do you mean, it's not like that at all. You only get back the same object (same reference) if it detects the object was immutable to begin with.

Ok, fine. That's just what I got from the quoted text. But I see that was wrong.