HaloO,
Moritz Lenz wrote:
TSa wrote:
The 'is rw' is on the method but I guess it is foreseen that the
result is stored in $string without preserving the identity of the
string?
No. It means that the Str object has to get hold of the container in
which it is stored, and store a modified copy in it. If that fails (for
example in "abc".substr(0, 1) = "foo", where "abc" isn't in a container
at all) the write operation will fail.
Sorry, I don't understand why you say 'no' and then explain that the
resulting new string is stored in the container. The only container
that could be affected by this is $string in the example. The way for
a method to get access to the container is by declaring a parameter
as rw. Note that this brings the discussion back to the point how rw
is handled in dispatch and if an anonymous container is autovivified
for a naked value. Did you mean the 'no' as answer to the question if
the identity of the string--i.e. its pointer--is preserved? This would
violate the immutability assertion of string values.
Is it generally foreseen that an object knows about the containers
it is stored in? Furthermore is it informed which of these is currently
used as lvalue in a mutating operation? I think both are expensive and
much better handled through the rw declaration of parameters because
at binding time the container is available.
Regards, TSa.
--
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan