[plt-scheme] equal? operator
However,
Suppose I have a structure type for which some fields
must be hidden (eg a semphore field) from equal?
Would this be possible?
--
Hans
Hans Oesterholt-Dijkema wrote:
> Thanks!
>
> Danny Yoo schreef:
>
>> On Sun, 20 Nov 2005, Hans Oesterholt-Dijkema wrote:
>>
>>
>>
>>> Is it possible to extend the equal? operator for new (structure) types
>>> in mzscheme?
>>>
>>
>>
>> Hi Hans,
>>
>>
>> According to:
>>
>> http://download.plt-scheme.org/doc/299.400/html/mzscheme/mzscheme-Z-H-4.html#node_idx_744
>>
>>
>> doing equal? on structures should just work, as long as the
>> structures are
>> inspectable. For example:
>>
>> ;;;;;;
>>
>>
>>> (define-struct pair (x y))
>>> (define p1 (make-pair 1 2))
>>> (define p2 (make-pair 1 2))
>>> (equal? p1 p2)
>>>
>>
>> #f
>> ;;;;;;
>>
>> Here, because the structure isn't inspectable, equal? doesn't work. But
>> if we make an inspectable structure:
>>
>> ;;;;;;
>>
>>
>>> (define-struct pair (x y) (make-inspector))
>>> (define p1 (make-pair 1 2))
>>> (define p2 (make-pair 1 2))
>>> (equal? p1 p2)
>>>
>>
>> #t
>> ;;;;;;
>>
>> equal? now is allowed to do the kind of equality testing we'd expect.
>>
>>
>>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme