[plt-scheme] equal? operator

From: Hans Oesterholt-Dijkema (hdnews at gawab.com)
Date: Sun Nov 20 18:55:17 EST 2005

Hi Matt,

Yes, I think I can. Although this means I think that
I need to use the module that redefines the eq? function
as a base function for modules that derive from it.

However, suppose I have three re-definitions of
eq? One for a new say 'array' type; one for a new
say 'object/class' type and some other.

What then?

Hans


Matt Jadud schreef:

> Hi Hans,
>
> Can't you use the module system? I may not understand what you want to 
> do, however.
>
> (module somestruct mzscheme
>   (provide (all-defined))
>
>   (define-struct foo (field)))
>
> (module redef mzscheme
>   (require somestruct)
>   (provide
>    (all-from somestruct)
>    (rename myequal? equal?))
>
>   (define (myequal? a b)
>     (cond
>       [(and (foo? a) (foo? b))
>        (equal? (foo-field a)
>                (foo-field b))]
>       [else
>        (equal? a b)])))
>
> (require redef)
>
> #|
> > (define foo1 (make-foo 3))
> > (define foo2 (make-foo 5))
> > (equal? foo1 foo2)
> false
> > (foo? foo1)
> true
> > (define foo3 (make-foo 3))
> > (equal? foo3 foo1)
> true
> >
> |#
>
> Hans Oesterholt-Dijkema wrote:
>
>> Oh, and is it maybe also possible to extend eq?
>> I'd like eq? to work differently for persistent roos
>> objects, comparing their Object Identifiers instead
>> of their "memory" locations.
>>
>>
>>
>> Hans Oesterholt-Dijkema schreef:
>>
>>> Dear All,
>>>
>>> Is it possible to extend the equal? operator for new (structure) types
>>> in mzscheme?
>>>
>>> -- 
>>> Hans Oesterholt-Dijkema
>>>
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>>
>>
>>
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



Posted on the users mailing list.