<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
                                        Hi Florin, hi Clément --<div><br></div><div>yes, that's what Squeak's #becomeForward:copyHash: is for.</div><div><br></div><div>See this discussion, where the interference between #becomeForward:, copy hash, and ModificationForbidden is explained:</div><div><a href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-April/208596.html"><span style="font-size: 10pt">http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-April/208596.html</span></a><br></div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div><blockquote class='history_container' type='cite' style='border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;'>
                        <p style='color: #AAAAAA; margin-top: 10px;'>Am 24.01.2022 08:04:38 schrieb Clément Béra <bera.clement@gmail.com>:</p><div style='font-family:Arial,Helvetica,sans-serif'> Hi Florin, <br> <br>I believe there are 2 primitives for 2 different use-cases: <br>- primitiveArrayBecomeOneWayNoCopyHash 248 <br>- primitiveArrayBecomeOneWayCopyHash 249 <br> <br>The difference between both is which hash is preserved. I think for your <br>use-case you should use the other primitive. <br> <br>On Mon, Jan 24, 2022 at 5:04 AM Florin Mateoc <florin.mateoc@gmail.com> <br>wrote: <br> <br>> <br>> Hi, <br>> <br>> I am a bit surprised by the #becomeForward: behavior in Squeak. This is a <br>> one way become, where the target of the operation is the receiver, which <br>> sheds its identity/existence. Nobody points to it after the primitive <br>> execution, so it is discarded. This understanding also conforms to the <br>> method comment. <br>> As such, I remember a pattern of usage in VisualAge Smalltalk, where one <br>> way become was used as a cheap cleanup/avoidance of memory leaks, by doing <br>> oneWayBecome: nil. It's not that I advocate for it, but this works in <br>> Squeak too, except in Squeak #becomeForward: does an additional thing to <br>> the pointers redirection, it changes the identityHash of the argument, the <br>> non (obvious) target. While I understand this may be useful in certain <br>> situations, I think it is a dangerous conflation of activities. A new <br>> primitive that sets the identity hash could be used (VA has it) explicitly <br>> instead when such behavior is desired. <br>> As it is, if I do "Object new becomeForward: nil", it succeeds and it <br>> changes nil's identityHash. <br>> <br>> Sorry if this has been debated before, <br>> <br>> Cheers, <br>> Florin <br>> <br> <br> <br>--  <br>Clément Béra <br>https://clementbera.github.io/ <br>https://clementbera.wordpress.com/ <br><div dir="ltr">Hi Florin,<br><br>I believe there are 2 primitives for 2 different use-cases:<br>- <span class="gmail-pl-c" style="box-sizing: border-box;font-family: ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size: 12px;white-space: pre">primitiveArrayBecomeOneWayNoCopyHash </span><span class="gmail-pl-c" style="box-sizing: border-box;font-family: ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size: 12px;white-space: pre">248</span><div><span style="color: rgb(36,41,47);font-family: ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size: 12px;white-space: pre">- </span><span style="color: rgb(36,41,47);font-family: ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size: 12px;white-space: pre">primitiveArrayBecomeOneWayCopyHash </span><span style="font-family: ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size: 12px;white-space: pre">249</span></div><div><span style="color: rgb(36,41,47);font-family: ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;font-size: 12px;white-space: pre"><br></span></div>The difference between both is which hash is preserved. I think for your use-case you should use the other primitive.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 24, 2022 at 5:04 AM Florin Mateoc <<a href="mailto:florin.mateoc@gmail.com">florin.mateoc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div>Hi,</div><div><br></div><div>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. <br></div><div>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  <br>instead  <br> <br>when such behavior is desired.</div><div>As it is, if I do "Object new becomeForward: nil", it succeeds and it changes nil's identityHash.</div><div><br></div><div>Sorry if this has been debated before,</div><div><br></div><div>Cheers,</div><div>Florin<br></div></div> <br></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><span style="font-size: 12.8px">Clément Béra<br></span><span style="color:rgb(0,0,238)"><a href="https://clementbera.github.io/" target="_blank">https://clementbera.github.io/</a></span><div style="font-size: 12.8px"><a href="https://clementbera.wordpress.com/" target="_blank">https://clementbera.wordpress.com/</a></div></div></div></div></div></div> <br></florin.mateoc@gmail.com></div></blockquote>
                                        </div></body>