[plt-scheme] equal? operator
Matthew Flatt schreef:
>At Mon, 21 Nov 2005 16:59:51 -0500, Eli Barzilay wrote:
>
>
>>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.
>>
>>
>
>Or structure-type properties. (That's what we use, for example, to
>support customizable object serialization.)
>
>
Yes indeed. What does 'equal?' mean? It means two variables are equal in
content.
How far does this have to go? Why can't there be hidden content?
>Specifically, we could add a property to MzScheme for setting a struct
>type's equality predicate, and `equal?' would check the property for
>each struct instance tat it encounters.
>
>The only problems with an equality-test property are the same as in
>Java: fitting the equality function into a single-dispatch system, and
>supporting a hash-function property whose value must be consistent with
>the equality property value. (Are there other issues?)
>
>So, we could change MzScheme --- or you could support a type-specific
>equality procedure in your own implementation `equal?', as long as you
>control all the uses of `equal?'.
>
>
Well, I'm currently not that much in need of an equal? operation. What I
really needed was an
eq? operation on PROOS objects (which I have right now).
>Matthew
>
>
>