Christophe Weblog Wiki Code Publications Music
call NO-APPLICABLE-METHOD in the appropriate place
authorChristophe Rhodes <csr21@cantab.net>
Fri, 7 Feb 2014 10:05:21 +0000 (10:05 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Fri, 7 Feb 2014 10:05:21 +0000 (10:05 +0000)
Otherwise we end up with NO-PRIMARY-METHODs.  We should only compute
an EMF if there are in fact some methods, or at least that seems to be
the current behaviour of SB-MOP:COMPUTE-EFFECTIVE-METHOD-FUNCTION

signum-specializer.lisp
specializable.lisp

index a5d21fa2d5ca1b2c026813a3f60384d34dbe42bb..ab7c0de346b2470adf65d7fee5c03b4ef93470f1 100644 (file)
    (defmethod fact ((n (signum 0))) 1)
    (defmethod fact ((n (signum 1))) (* n (fact (1- n))))
    (assert (eql (fact 6) 720))
-   (assert (eql (fact 6.0) 720.0))))
+   (assert (eql (fact 6.0) 720.0))
+   (defmethod no-applicable-method ((gf (eql #'fact)) &rest args)
+     'gotcha)
+   (assert (eql (fact -6) 'gotcha))))
 
 (eval
  '(progn
index ebe4794a44bdbe7d51212df995df3a599101f17b..1df14d403054fd46587736e6fa672688d4d62b11 100644 (file)
                             args))))
 
 (defun compute-effective-method-function (gf methods)
-  (let* ((mc (sb-mop:generic-function-method-combination gf))
-         (sb-pcl::*applicable-methods* methods)
-         (em (sb-mop:compute-effective-method gf mc methods)))
-    (sb-pcl::make-effective-method-function gf em)))
+  (if (null methods)
+      (lambda (&rest args) (apply #'no-applicable-method gf args))
+      (let* ((mc (sb-mop:generic-function-method-combination gf))
+             (sb-pcl::*applicable-methods* methods)
+             (em (sb-mop:compute-effective-method gf mc methods)))
+        (sb-pcl::make-effective-method-function gf em))))
 
 ;; new, not in closette
 (defgeneric generalizer-of-using-class (generic-function object))