[plt-scheme] equal? operator

From: Hans Oesterholt-Dijkema (hdnews at gawab.com)
Date: Mon Nov 21 17:47:11 EST 2005

Eli Barzilay schreef:

>The equal? that you're describing is one that can be extended for new
>types (you said that simply overriding `equal?' won't work), and you
>don't want to simply compare all slots recursively (as you get when
>using a proper inspector).  So it seems like what you realy need is a
>generic equal? operation that will do the proper dispatch based on the
>input type, with the ability to define new behaviors for new typs.
>This sounds like something an OO system should let you do.
THanks, I'll look into this.

>Overriding eq? is dangerous, since everyone assumes that eq? objects
>are always the same pointer.  What you want is to use some other way
>of identifying when an object is the same as some other object.  It
>may be fine to override eq? as this new operation in your case, but in
>general it doesn't work, since if you mutate one of these objects the
>other does not automatically change.
>One obvious solution is to use a new equality operation like you had,
>but my guess is that this is not the right solution for your case.
>What is more likely is that you need an extra interface layer that
>`interns' values.  This is usually done by a (weak) hash table that
>psearch will use -- whenever you're looking for an object, you look in
>the hash table first and return the value you find, or retrieve the
>actual value and store it in the table.
In the this specific case, the psearch  operation executes a RPC to a 
server. The server
returns OIDs on which bases PROOS objects are created. When I access a 
variable of a PROOS object, its value is actually read via RPC. When I 
set a member
variable of a PROOS object, its value is actualle stored via RPC and all 
other PROOS
objects with the same OID will read this value on the next read.  There 
is caching involved,
but that's transparent.

But still, you have a good point. I can declare a PROOS class with 
persistent and non-persistent
attributes. The non-persistent attributes for a and b with the same OID 
can have different

So, what I will do, is indead take your advice and try to create a weak 
hash table holding
all the proos variables currently active in memory.


Posted on the users mailing list.