On 06/20/2015 12:36 AM, Andrei Alexandrescu wrote:
On 6/19/15 2:23 PM, Timon Gehr wrote:
What makes persistent data structures useful is that they provide _value
semantics_ for complex data types with _O(1)_ copies and fast updates.
(COW has only the first two of those.)

OK, so SList!int should allow mutating individual values, and
SList!(immutable int) shouldn't? Or does that apply only to objects with
indirections?

Forgot to answer to this.

E.g:

struct ListInt6{int front,b,c,d,e,f; }

auto x = ListInt6(1,2,3,4,5,6);
auto y = x;
x.front = 2;
assert(x.front==2);
assert(y.front==1); // value semantics


auto x = SList!int(1,2,3,4,5,6);
auto y = x;

x.front=2;
assert(x.front==2);
assert(y.front==1); // value semantics

It is not absolutely crucial that this works, but then, why shouldn't it work? It works for structs.


Reply via email to