From: Christophe Rhodes Date: Fri, 7 Feb 2014 11:52:59 +0000 (+0000) Subject: add one more "interesting" signum method X-Git-Url: http://christophe.rhodes.io/gitweb/?p=paper-els-specializers.git;a=commitdiff_plain;h=ad5a5f9adaf1aa472f2cc563ae475577cca6089a add one more "interesting" signum method --- diff --git a/els-specializers.org b/els-specializers.org index 9094ad2..b4e3e79 100644 --- a/els-specializers.org +++ b/els-specializers.org @@ -166,6 +166,12 @@ (if (= (%signum s) (%signum g)) ; or EQL? (values t t) (values nil t))) + +;; this method is perhaps interesting enough to talk about? +(defmethod specializer-accepts-generalizer-p ((gf signum-generic-function) (specializer sb-mop:specializer) (thing signum-specializer)) + (specializer-accepts-generalizer-p gf specializer (class-of (%signum thing)))) + + (defmethod specializer-accepts-p ((s signum-specializer) o) (and (realp o) (= (%signum s) (signum o)))) @@ -173,8 +179,8 @@ (defgeneric fact (n) (:generic-function-class signum-generic-function)) -(defmethod fact ((n (signum 1))) (* n (fact (1- n)))) (defmethod fact ((n (signum 0))) 1) +(defmethod fact ((n (signum 1))) (* n (fact (1- n)))) (defmethod fact ((n (signum -1))) (error "factorial of negative number: ~D" n)) #+end_src