[Vm-dev] Why become should fail on readonly objects?

Denis Kudriashov dionisiydk at gmail.com
Wed Jan 10 10:46:42 UTC 2018


Hi.

Look at following example:

p1 := 10 at 20.
p2 := 40 at 50.
p1 becomeForward: p2.
p1 == p2 "==> true"


It shows that become operation do not modifies p1 instance. It just
replaces value in all references.
Now if p1 will be read only object then become will fail:

p1 := 10 at 20.
p2 := 40 at 50.

p1 beReadOnlyObject.

p1 becomeForward: p2. "==> fail by modification error"

My question is why this logic is valid? As simple user I do not see how
become modifies the state of receiver p1.

And what I expect is failing on another case which surprisingly do not fail:

p1 := 10 at 20.
p2 := 40 at 50.
array := {  p1. p2}.
array beReadOnlyObject.
p1 becomeForward: p2.

array = {40 at 50. 40 at 50} "==true"

Here become operation modifies state of read only object. But it not fails.

Best regards,
Denis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20180110/c7a71baa/attachment.html>


More information about the Vm-dev mailing list