summaryrefslogtreecommitdiff
path: root/module/oop
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-11-08 11:49:06 +0100
committerAndy Wingo <wingo@pobox.com>2009-11-26 00:25:07 +0100
commit9f63ce021c567056c02b81d96742ff91416b886f (patch)
treecf209c811574b7a77b937af9d975b7f2c459ba41 /module/oop
parent72d2e7e65f1895df9c527e792a05674d02dcac9a (diff)
downloadguile-9f63ce021c567056c02b81d96742ff91416b886f.tar.gz
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.
Diffstat (limited to 'module/oop')
-rw-r--r--module/oop/goops.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/module/oop/goops.scm b/module/oop/goops.scm
index d06f62f6c..c8a183bcf 100644
--- a/module/oop/goops.scm
+++ b/module/oop/goops.scm
@@ -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