about equal? Peter Lane (09 May 2017 21:07 UTC)
Re: about equal? John Cowan (09 May 2017 21:45 UTC)
Re: about equal? Shiro Kawai (09 May 2017 23:05 UTC)
Re: about equal? Per Bothner (09 May 2017 23:30 UTC)

about equal? Peter Lane 09 May 2017 21:06 UTC

While porting the test suite to SRFI 64 and testing on R7RS
implementations I found that Chibi and Sagittarius scheme worked
similarly to Chicken, in that equal? naturally works with ilists.
However, Gauche, Kawa and Larceny do not.

I then saw the statement: "Added after finalization: Implementers should
extend the Scheme predicate equal? to descend into immutable pairs in
the same way that it descends into mutable pairs."

I'm not sure if this is the best solution, but I have exported an
iequal? function (copied below) from the library for those
implementations that require it.

For imember, iassoc etc (all with a maybe-= input), I replaced the
default equal? with iequal?.

In my SRFI 64 test suite I replaced test-equal with itest-equal:

(define (itest-equal a b) (test-assert (iequal? a b)))

Finally, the tests all pass on the five R7RS implementations.

I tried exporting my iequal? function as equal? but this did not "pass
into" the test-equal method (presumably as it's defined in SRFI 64, and
the library scope is preserving its own definition of equal?).

Does this sound a reasonable way forward to manage equality with ilists?
  Or does anyone have an alternative technique they are using?

thanks,

     Peter.
--
Peter Lane
http://peterlane.info/scheme.html

My implementation of iequal?:

   (cond-expand
     ((or gauche kawa larceny)
      (import (only (scheme list) every))
      (begin
        (define (iequal? a b)
          (cond ((and (ilist? a)
                      (ilist? b))
                 (ilist= iequal? a b))
                ((and (ipair? a)
                      (ipair? b))
                 (and (iequal? (icar a) (icar b))
                      (iequal? (icdr a) (icdr b))))
                ((and (vector? a)
                      (vector? b))
                 (iequal? (vector->list a) (vector->list b)))
                ((and (list? a)
                      (list? b))
                 (every iequal? a b))
                (else
                  (equal? a b))))))
     (else ; (or chibi sagittarius)
      (begin
        (define iequal? equal?))))