mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 01:00:20 +02:00
make sure that when equal? is extended, that the generic has a method
* libguile/goops.h: * libguile/goops.c (scm_set_primitive_generic_x): New function, for now local to the goops module. * module/oop/goops.scm (equal?): Make sure that when equal? is extended, that the generic already has a default method.
This commit is contained in:
parent
72d2e7e65f
commit
9f63ce021c
3 changed files with 23 additions and 1 deletions
|
@ -716,7 +716,15 @@
|
|||
;;; Methods to compare objects
|
||||
;;;
|
||||
|
||||
(define-method (equal? x y) (eqv? x y))
|
||||
;; Have to do this in a strange order because equal? is used in the
|
||||
;; add-method! implementation; we need to make sure that when the
|
||||
;; primitive is extended, that the generic has a method. =
|
||||
(define g-equal? (make-generic 'equal?))
|
||||
;; When this generic gets called, we will have already checked eq? and
|
||||
;; eqv? -- the purpose of this generic is to extend equality. So by
|
||||
;; default, there is no extension, thus the #f return.
|
||||
(add-method! g-equal? (method (x y) #f))
|
||||
(set-primitive-generic! equal? g-equal?)
|
||||
|
||||
;;;
|
||||
;;; methods to display/write an object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue