Hacker News new | ask | show | jobs
by evilotto 1546 days ago
I rather like tcl's solution: copy on write, with reference counting. Values are immutable, so if you to alter a value in place, it gets copied; but iff nothing else is pointing to the same value it can get modified in place because the end result is indistinguishable. This does lead to the occasional need to explictly unshare things for performance[1], at least until the compiler gets smart enough to prove that the value is unshared.

[1] https://wiki.tcl-lang.org/page/K#c2a6014c2d129837889d8a8000d...