> > Recently I noticed, that srfi-64 `assert-equal` macro do not use
> > `equal?` that was redefinded via `define-method` in scope of invocation
> > of `assert-equal`.
> No, that’s normally not a problem: (define-method (equal? ...) ...)
> should turn the core ‘equal?’ primitive into a generic function, and
> things would work well because (@@ (srfi srfi-64) equal?) is the same
> as (@ (guile) equal?).

> How exactly did you define ‘equal?’ methods?
I define class object as

    (module-define! (current-module) '<struct-foo>
        (make <class> #:dsupers (list <object>) #:slots ...))

and after just

(define-method (equal? x y)
  ((@ (guile) equal?) x y))

(define-method (equal? (this <object>) (other <object>))
  (let* ((class_ (class-of this))
         (slots (map car (class-slots class_))))
    (define (slot-values instance)
      (map (cute slot-ref instance <>) slots))
    (if (eq? class_ (class-of other))
        (false-if-exception (equal? (slot-values this) (slot-values other)))
      #f)))

I do not know, why first one `equal?` is needed, but otherwise guile
complained, that no method is present to compare two lists.

Interesting enough, I created simple module, and behaves as it should.
Maybe you have some wild guess about class being defined not via macro?

--
Best regards, Dmitry Bogatov <[email protected]>,
Free Software supporter, esperantisto and netiquette guardian.
GPG: 54B7F00D

Attachment: pgp6yG42DCGQS.pgp
Description: PGP signature

Reply via email to