Christophe Weblog Wiki Code Publications Music
add one more "interesting" signum method
authorChristophe Rhodes <csr21@cantab.net>
Fri, 7 Feb 2014 11:52:59 +0000 (11:52 +0000)
committerChristophe Rhodes <csr21@cantab.net>
Fri, 7 Feb 2014 11:52:59 +0000 (11:52 +0000)
els-specializers.org

index 9094ad2a303dc00b544c7e905a7f028e58cd2893..b4e3e79bdc188ddb08c098202be4db8ce6ae96cd 100644 (file)
   (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))))
 
 
 (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