On 23/03/12 20:42, Graydon Hoare wrote:
- Existing vecs are always unique. Sometimes you want shared, but
boxing them as @[] causes double-indirection, feels awkward.
Apologies if I am missing the point here, but how about using some sort
of copy-on-write mechanism instead of unique pointers? So:
let x = [1, 2, 3];
let y = x; // increments the reference count of the vec
referenced to by x
let x += [4]; // since [the vec referenced to by] x has more then
one reference, it cant be appended in-place, so this is a
copy-and-then-append operation
let x += [5]; // since x only has one reference now, it can be
appended-in-place
I believe Tcl does something like this.
-Gareth
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev