Can't access objects in dictionary

Chris Muller asqueaker at gmail.com
Fri Dec 31 16:58:23 UTC 2010


Hi Amir, each session has its *own* view of the persistent object
model.  It's own copy.  It _must_ be that way, or else when one
session changes an object it will appear "changed" for the other
sessions too.

You are perfectly welcome to use identity-based checking in your Magma
programs, as long as you do the check on objects from the same
session.

However, as previously stated, you must ensure that identityHash is
never part of the hash calculation, because the hash determines its
position in the Dictionary, and it will not be the same between
sessions.

HTH,
  Chris

On Fri, Dec 31, 2010 at 7:10 AM, Amir Ansari <fractallyte at csi.com> wrote:
> Hi Facundo
>
> Thanks for your help.  What I'm trying to understand is how, between different Magma sessions, the Dictionary keys seem to 'lose' their identity.  Obviously, the first thought is that there's something wrong in my code (which I why I posted it all).  Surely it should be simple to check directly whether an object equals a key, without having to define hash methods...?
>
> I ought to point out that I also tested these steps separately without committing in a Magma session, and everything worked OK.
>
> Amir
>
>
> On Thu, 30 Dec 2010 16:48:32 -0300
> Facundo Vozzi <facundov79 at gmail.com> wrote:
>
>> Hi Amir,
>> did you define #= method on User ?
>>
>> I guest that It'll look like this:
>>
>> User >> = otherUser
>> "Answer whether the receiver is equal to the argument."
>>  self class = otherUser class ifFalse: [^false].
>> ^self name = otherUser name
>>
>> You need implement the #hash method too:
>>
>> User >> hash
>> "Answer a SmallInteger whose value is related to the receiver's identity."
>>  ^self name hash
>>
>> Hope this help.
>>
>> Facu
> _______________________________________________
> Magma mailing list
> Magma at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/magma
>


More information about the Magma mailing list