(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
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))