|
From: Andreas L. <av...@lo...> - 2008-01-18 08:33:59
|
On Fri, Jan 18, 2008 at 12:53:17AM +0100, Alexandre Ferrieux wrote:
> Mutability - principle
> -----------------------------
> ...
Maybe, you would have mentioned it anyway, sooner or later,
But I'm curious now about the following:
set m [create mutable list with initial elements: 1 2 3]
set n $m
lset m 0 foo; # $m now "foo 2 3", ditto $n
so far so clear, but:
set o [lreplace $m 1 2 bar]; # $o now "foo bar", $m,$n unchanged(?)
set m $o ; # does this modify the mutable list, or replace it?
Since you mention "in-place" modifying operations, my guess is,
that [lreplace...] would not modify a passed in mutable list, but
just create a new (mutable?) one.
What would be the procedure to apply a command like lreplace
to a mutable list, such as to "fake" an in-place operation on
the mutable list, such that it would then be visible to other
holders of that list-value?
PS: I consider this question orthogonal to what we disagreed on
before :-)
|