<div dir="ltr">Hi,<div><br></div><div>    I don&#39;t see the bug.  Look at this example:</div><div><br></div><div><div>| a b ha hb |</div><div>a := Object new.</div><div>b := Object new.</div><div>ha := a identityHash.</div><div>hb := b identityHash.</div><div>a becomeForward: b copyHash: true.</div><div>{ ha = hb. a == b. a identityHash == ha }. #(false true true)</div></div><div><br></div><div>So here a has indeed become b; all references to a are now references to b.  But b&#39;s identityHash is now that of what a&#39;s was before the become.  That&#39;s as specified.</div><div><br></div><div>Let&#39;s extend the example:</div><div><br></div><div><div>| a b ha hb is |</div><div>a := Object new.</div><div>b := Object new.</div><div>is := IdentitySet new.</div><div><b>is add: b.</b></div><div>ha := a identityHash.</div><div>hb := b identityHash.</div><div>a becomeForward: b copyHash: true.</div><div>{ ha = hb. a == b. a identityHash == ha. <b>is includes: a</b> }. #(false true true false)</div></div><div><br></div><div>This is correct; a (and b) is (are) now in the set at the old hash of b, which is no longer its hash.  So...</div><div><br></div><div><div>| a b ha hb is |</div><div>a := Object new.</div><div>b := Object new.</div><div>is := IdentitySet new.</div><div>is add: b.</div><div>ha := a identityHash.</div><div>hb := b identityHash.</div><div>a becomeForward: b copyHash: true.</div><div><b>is rehash.</b></div><div>{ ha = hb. a == b. a identityHash == ha. is includes: a }. #(false true true true)</div></div><div><br></div><div>Good.</div><div><br></div><div>So instead what you might have meant to say was</div><div><br></div><div><div>| a b ha hb is |</div><div>a := Object new.</div><div>b := Object new.</div><div>is := IdentitySet new.</div><div><b>is add: a.</b></div><div>ha := a identityHash.</div><div>hb := b identityHash.</div><div>a becomeForward: b copyHash: true.</div><div>{ ha = hb. a == b. a identityHash == ha. is includes: a }. #(false true true true)</div></div><div><br></div><div>That looks good.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 27, 2016 at 2:50 AM, <a href="mailto:tesonep@gmail.com">tesonep@gmail.com</a> <span dir="ltr">&lt;<a href="mailto:tesonep@gmail.com" target="_blank">tesonep@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,  <div>       I&#39;m trying to become forward some objects, these objects are stored in IdentitySets so I need to copy the identityHash of the older objects to the new ones. So that the IdentitySets are still well constructed.</div><div><br></div><div>I have read the comments in Array &gt;&gt; elementsForwardIdentityTo: copyHash: , and Array &gt;&gt; elementsForwardIdentityTo:, so I realise that the operation I want to use is the first with copyHash in true or the later (that should be doing the same, from the comments).</div><div><br></div><div>But after trying it, it is not working as expected. </div><div><br></div><div>If I try with:</div><div><br></div><div><div>x := Object new.</div><div>y := Object new.</div><div>z := Object new.</div><div><br></div><div>set := IdentitySet new.</div><div>set add: x.</div><div>set add: y.</div><div><br></div><div>hash := x identityHash.</div><div>bhash := x basicIdentityHash.</div><div><br></div><div>self assert:(set isHealthy).</div><div><br></div><div>z becomeForward: x copyHash: true.</div><div><br></div><div>set isHealthy &quot;false&quot;</div><div><br></div><div>z basicIdentityHash  = bhash. &quot;false&quot;</div><div>z identityHash = hash &quot;false&quot;</div><div><br></div><div>It is not working, but if I changed the copyHash parameter to false, it works. </div><div><br></div><div>Something is not right (the comment or the implementation), because the comment says:</div><div><br></div><div>&quot;If copyHash is true, the identityHashes remain with the pointers rather than with the</div><div><span style="white-space:pre-wrap">        </span> objects so that the objects in the receiver should still be properly indexed in any</div><div><span style="white-space:pre-wrap">        </span> existing hashed structures after the mutation.  If copyHash is false, then the hashes</div><div><span style="white-space:pre-wrap">        </span> of the objects in otherArray remain unchanged.&quot;</div><div><br></div><div>Do I have understanded everything wrong or there is something that is not working (or at least the comment is not clear)</div><div><br></div><div>Is somebody using these operations?  How do you expect to work?</div><div><br></div><div>Maybe If you can  help me to understand the situation I can fix the comments. </div><div><br></div><div>Thanks in advance.</div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div data-smartmail="gmail_signature">Pablo Tesone.<br><a href="mailto:tesonep@gmail.com" target="_blank">tesonep@gmail.com</a></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div>