<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 17, 2016 at 11:42 AM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> <br><br>
&gt; On 17.03.2016, at 13:52, David T. Lewis &lt;<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Mar 17, 2016 at 09:57:51AM +0100, Denis Kudriashov wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi.<br>
&gt;&gt;<br>
&gt;&gt; I investigate that #becomeForward: is not working for SmallInteger args. It<br>
&gt;&gt; is mentioned in method comment:<br>
&gt;&gt;<br>
&gt;&gt; Fails if either argument is a SmallInteger.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I guess that it is not working for any immediate argument. For example it<br>
&gt;&gt; is failed for Character too.<br>
&gt;&gt;<br>
&gt;&gt; So I am interesting why it is not supported?<br>
&gt;<br>
&gt; The become mechanism is swapping references to objects, such that the<br>
&gt; object pointers that pointed to one object are all now pointing to another.<br>
&gt; An immediate object such as SmallInteger is hiding its value within the<br>
&gt; object pointer itself (so it not really a pointer when used in this way).<br>
&gt; The immediate object &quot;pointer&quot; is therefore not able to participate in<br>
&gt; reference swapping.<br>
<br>
Well, that’s no reason we couldn’t just replace all references to the object with the immediate value.<br>
<br>
There’s only one technical reason I am aware of, and that is that becomeForward actually does change the argument’s identityHash:<br>
<br></blockquote><div><br></div><div><br></div><div>Couldn&#39;t that be solved using the #becomeForward:copyHash: flavor (passing `false` to copyHas:) ?</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
old := ‘old&#39;.<br>
new := ’new&#39;.<br>
idold := old identityHash.<br>
idnew := new identityHash.<br>
old becomeForward: new.<br>
{idold. idnew. new identityHash}<br>
<br>
==&gt; #(153 3753 153)<br>
<br>
In this case, b’s identity hash changed from 3753 to 153.<br>
<br>
This mechanism exists so that if ‘old’ was used as key in an IdentityDictionary before, then now ‘new’ can be found at the same position because it uses the same hash. And since there is no way to change the identity hash of an immediate value, this can not work.<br>
<br>
<br>
&gt; On 17.03.2016, at 14:35, Denis Kudriashov &lt;<a href="mailto:dionisiydk@gmail.com">dionisiydk@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; So to implement becomeForward: with integer argument it is needed to scan all references to receiver and change pointers body to hold integer value.<br>
&gt; Am I right?<br>
<br>
What *does* work, however (at least in Cog and SqueakJS, although not in the interpreter) is to use &#39;becomeForward: new copyHash: false’:<br>
<br>
old := &#39;hi&#39;.<br>
old becomeForward: 3 copyHash: false.<br>
old<br>
==&gt; 3<br>
<br>
... because in the “copyHash: false” case the argument object is not modified in any way.<br>
<br>
- Bert -<br>
<br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br></div>
</div></div>