Christophe Weblog Wiki Code Publications Music
call NO-APPLICABLE-METHOD in the appropriate place
[specializable.git] / specializable.lisp
index b74d73fdd506347aa61dd14de4b71f94ecbfe70e..1df14d403054fd46587736e6fa672688d4d62b11 100644 (file)
@@ -20,6 +20,7 @@
 (in-package "SPECIALIZABLE")
 
 (defclass extended-specializer (sb-mop:specializer)
+  ;; FIXME: this doesn't actually do quite what I wanted.
   ((direct-methods-table :allocation :class
                          :initform nil :accessor direct-methods-table)))
 
 
 ;;; FIXME: in some kind of order, the discriminating function needs to handle:
 ;;; - argument count checking;
-;;; - keyword argument validity;
+;;; - DONE (in effective method) keyword argument validity;
 ;;; - DONE flushing the emf cache on method addition/removal
 ;;; - DONE (sort of, using wrappers/g-e-h-k) flushing the cache on class redefinition;
 ;;; - cache thread-safety.
       (compute-applicable-methods-using-generalizers gf generalizers)
     (if definitivep
        (let* ((emfun
-               (compute-effective-method-function gf applicable-methods))
+                (compute-effective-method-function gf applicable-methods))
                (keys (mapcar (lambda (x) (generalizer-equal-hash-key gf x)) generalizers)))
          (setf (gethash keys (emf-table gf)) emfun)
          (sb-pcl::invoke-emf emfun args))
-       (sb-pcl::invoke-emf (compute-effective-method-function
+        (sb-pcl::invoke-emf (compute-effective-method-function
                              gf (sb-mop:compute-applicable-methods gf args))
                             args))))
 
 (defun compute-effective-method-function (gf methods)
-  (let* ((mc (sb-mop:generic-function-method-combination gf))
-         (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))