TSa Thomas.Sandlass-at-vts-systems.de |Perl 6| wrote:
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.
For "rw" yes, for "ref" no.
Yes. But it is not generally the case that this is the same container
as the caller is holding. Detailed specifications of the meaning of
'read-only', 'rw', 'copy', and 'ref' and the binding semantics thereof
need to address this, and address the concerns of efficient implementations.
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?
But off the cuff, I think it is safe to say that 'ref' parameters are
guaranteed to have the same container that the caller sees, and 'copy'
parameters are guaranteed not to. default (read-only) passing may or
may not at the implementation's whim, but you won't change it so it
doesn't matter. 'rw' may allow the value to change before binding;
'ref' never permits that.