Re: Circular structures [was Re: IEEE 754 floating-point arithmetic is not completely ordered] Jens Axel Søgaard 18 Apr 2005 20:31 UTC

Bradley Lucier wrote:

> On Apr 16, 2005, at 10:53 AM, Jens Axel Søgaard wrote:
>
>> Bradley Lucier wrote:
>>
>>> Well, it depends on what your goal is. ...
>>
>> Here are some potential goals:
>> ...
>> 3) default-compare should define a total order on almost all Scheme
>> values
>
> What is "almost all"?

"Almost all" should be interpreted in the view of the design rationale
in the section "How to define default-compare?". We are excluding
objects such as closures and continuations, where the only
portable comparison operator available is eq?. If an implementation
offers additional possibilities (say based on hash codes and pointer
magic) then they could provide refined compare function.

We encourage implementors to refine default-compare on implementation
specific values such as such as values representing regular expressions.

> How do a and b compare in the following?

> [descartes:~/programs/folding/2] lucier% gsc
> loading /usr/local/Gambit-C/gambcext.scm
> Gambit Version 4.0 beta 12
>
>  > (define a (cons #f #f))
>  > (set-car! a a)
>  > (set-cdr! a a)
>  > (define b (cons #f #f))
>  > (set-car! b b)
>  > (set-cdr! b b)
>  > (equal? a b)   ;;; doesn't terminate
>
> Is default-compare compatible with equal?

We have on purpose left the result of default-compare unspecified
when one of the arguments is circular. Testing circularity is
expensive to do in a portable way.

--
Jens Axel Søgaard