Hi,

    I don't see the bug.  Look at this example:

| a b ha hb |
a := Object new.
b := Object new.
ha := a identityHash.
hb := b identityHash.
a becomeForward: b copyHash: true.
{ ha = hb. a == b. a identityHash == ha }. #(false true true)

So here a has indeed become b; all references to a are now references to b.  But b's identityHash is now that of what a's was before the become.  That's as specified.

Let's extend the example:

| a b ha hb is |
a := Object new.
b := Object new.
is := IdentitySet new.
is add: b.
ha := a identityHash.
hb := b identityHash.
a becomeForward: b copyHash: true.
{ ha = hb. a == b. a identityHash == ha. is includes: a }. #(false true true false)

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...

| a b ha hb is |
a := Object new.
b := Object new.
is := IdentitySet new.
is add: b.
ha := a identityHash.
hb := b identityHash.
a becomeForward: b copyHash: true.
is rehash.
{ ha = hb. a == b. a identityHash == ha. is includes: a }. #(false true true true)

Good.

So instead what you might have meant to say was

| a b ha hb is |
a := Object new.
b := Object new.
is := IdentitySet new.
is add: a.
ha := a identityHash.
hb := b identityHash.
a becomeForward: b copyHash: true.
{ ha = hb. a == b. a identityHash == ha. is includes: a }. #(false true true true)

That looks good.

On Mon, Jun 27, 2016 at 2:50 AM, tesonep@gmail.com <tesonep@gmail.com> wrote:
Hello,  
       I'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.

I have read the comments in Array >> elementsForwardIdentityTo: copyHash: , and Array >> 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).

But after trying it, it is not working as expected. 

If I try with:

x := Object new.
y := Object new.
z := Object new.

set := IdentitySet new.
set add: x.
set add: y.

hash := x identityHash.
bhash := x basicIdentityHash.

self assert:(set isHealthy).

z becomeForward: x copyHash: true.

set isHealthy "false"

z basicIdentityHash  = bhash. "false"
z identityHash = hash "false"

It is not working, but if I changed the copyHash parameter to false, it works. 

Something is not right (the comment or the implementation), because the comment says:

"If copyHash is true, the identityHashes remain with the pointers rather than with the
objects so that the objects in the receiver should still be properly indexed in any
existing hashed structures after the mutation.  If copyHash is false, then the hashes
of the objects in otherArray remain unchanged."

Do I have understanded everything wrong or there is something that is not working (or at least the comment is not clear)

Is somebody using these operations?  How do you expect to work?

Maybe If you can  help me to understand the situation I can fix the comments. 

Thanks in advance.

--
Pablo Tesone.
tesonep@gmail.com



--
_,,,^..^,,,_
best, Eliot