[Vm-dev] becomeForward: behavior

Florin Mateoc florin.mateoc at gmail.com
Mon Jan 24 04:04:43 UTC 2022


I am a bit surprised by the #becomeForward: behavior in Squeak. This is a
one way become, where the target of the operation is the receiver, which
sheds its identity/existence. Nobody points to it after the primitive
execution, so it is discarded. This understanding also conforms to the
method comment.
As such, I remember a pattern of usage in VisualAge Smalltalk, where one
way become was used as a cheap cleanup/avoidance of memory leaks, by doing
oneWayBecome: nil. It's not that I advocate for it, but this works in
Squeak too, except in Squeak #becomeForward: does an additional thing to
the pointers redirection, it changes the identityHash of the argument, the
non (obvious) target. While I understand this may be useful in certain
situations, I think it is a dangerous conflation of activities. A new
primitive that sets the identity hash could be used (VA has it) explicitly
instead when such behavior is desired.
As it is, if I do "Object new becomeForward: nil", it succeeds and it
changes nil's identityHash.

Sorry if this has been debated before,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20220123/026a2eaf/attachment.html>

More information about the Vm-dev mailing list