X-Git-Url: http://christophe.rhodes.io/gitweb/?p=paper-els-specializers.git;a=blobdiff_plain;f=els-specializers.org;h=b4e3e79bdc188ddb08c098202be4db8ce6ae96cd;hp=9094ad2a303dc00b544c7e905a7f028e58cd2893;hb=ad5a5f9adaf1aa472f2cc563ae475577cca6089a;hpb=317a6170fe01a4b158e06fd5616c7d5624a0e9ae 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