As Tobias says, typically the copy
message is implemented as a shallow copy.
Semantically, copy
in Self pretty much means 'give me a safe/useful copy'. For many objects this is just a shallow copy.
Objects are responsible for implementing their own copy
, either by delegating to a pure shallow copy method such as the implementation in traits clonable
or by having their own copy
slot.
For example, morphs typically respond to the copy
message by giving you a usable copy, rather than a shallow copy. Also objects which shouldn't be copied often implement or delegate to a method copy = (self)
so that attempts to copy just return the original object.
If you want a strict shallow copy, most copiable objects will respond to clone
though this should be used with care. And at the base is the VM defined primitive method _Clone
which is a shallow copy.