4 ms·
Sharing is both common and expected, as it arises naturally as a result of writing functions over variants. The language also provides an identity test (==) by
by gsg 13y ago
Sharing is both common and expected, as it arises naturally as a result of writing functions over variants. The language also provides an identity test (==) by which sharing can be observed, so it can't be said to be "behind the scenes".
Several of the data structures in the stdlib make good use of sharing to reduce the cost of operations - Set.union is a particularly good example. map, however, is not the sort of operation that leads to sharing.