Comment by jcparkyn
11 hours ago
Yes, if you modify a nested dict/list entry, all nodes above it will be cloned. Here's an example:
x = [1, [2]];
var y = x;
set y.[0] = 3; // clones the outer array, keeps a reference to inner array
set y.[1].[0] = 4; // clones the inner array here. Outer array is now exclusive so it doesn't need another clone.
var z = x;
set z.[1].[0] = 4; // clones both arrays at once
No comments yet
Contribute on Hacker News ↗