Christophe Weblog Wiki Code Publications Music
add one more "interesting" signum method
[paper-els-specializers.git] / 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