X-Git-Url: http://christophe.rhodes.io/gitweb/?p=specializable.git;a=blobdiff_plain;f=specializable.lisp;h=8d01319b1267e28a5da465263fbb8b4df27163c5;hp=e556db4caff1e2a2f0818c97ed64802111a4c097;hb=d55ebbbcbd77023c799d8d95dce5d3772aec5841;hpb=45b462c73d230a864be17e9bd701b5a421e635c1 diff --git a/specializable.lisp b/specializable.lisp index e556db4..8d01319 100644 --- a/specializable.lisp +++ b/specializable.lisp @@ -44,23 +44,28 @@ (remove-duplicates (mapcar #'sb-mop:method-generic-function (sb-mop:specializer-direct-methods specializer)))) (defclass specializable-generic-function (standard-generic-function) - ((extended-specializers :initform (make-hash-table :test 'equal) - :reader generic-function-extended-specializers) - (emf-table :initform (make-hash-table :test 'equal) :reader emf-table) + ((emf-table :initform (make-hash-table :test 'equal) :reader emf-table) (cacheingp :initform t :initarg :cacheingp) (single-arg-cacheing-p :initform t :initarg :single-arg-cacheing-p)) (:metaclass sb-mop:funcallable-standard-class) (:default-initargs :method-class (find-class 'specializable-method))) -(defclass specializable-method (standard-method) - ((lambda-expression :initarg :lambda-expression - :accessor specializable-method-lambda-expression))) +;;; TODO: we don't use this class yet, but we might do later +(defclass specializable-method (standard-method) ()) + +;;; TODO use info? +(defun extended-specializer-name-p (name) + (and (symbolp name) + (get name 'extended-specializer-parser))) + +(deftype extended-specializer-name () + `(satisfies extended-specializer-name-p)) (defmacro define-extended-specializer (name (gf-var &rest args) &body body) ;; FIXME: unparser `(setf (get ',name 'extended-specializer-parser) - (lambda (,gf-var ,@args) - ,@body))) + (lambda (,gf-var ,@args) + ,@body))) ;; doesn't work, because we'd have to dump GF into the fasl for the macro ;; expansion @@ -84,15 +89,10 @@ ;;; from SBCL: (defmethod sb-pcl:parse-specializer-using-class - ((gf specializable-generic-function) name) - (cond - ((typep name 'sb-mop:specializer) name) - ((symbolp name) (find-class name)) - ((consp name) - (case (car name) - (eql (sb-mop:intern-eql-specializer (cadr name))) - (t (make-extended-specializer name)))) - (t (error "unexpected specializer name")))) + ((gf specializable-generic-function) (specializer-name t)) + (if (typep specializer-name '(cons extended-specializer-name)) + (make-extended-specializer specializer-name) + (call-next-method))) (defmethod sb-pcl:make-method-specializers-form ((gf specializable-generic-function) method snames env) @@ -137,7 +137,7 @@ ;;; - DONE (sort of, using wrappers/g-e-h-k) flushing the cache on class redefinition; ;;; - cache thread-safety. ;;; - speed -;;; - interaction with TRACE et al. +;;; - DONE (in SBCL itself) interaction with TRACE et al. (defmethod sb-mop:compute-discriminating-function ((gf specializable-generic-function)) (cond ((not (slot-value gf 'cacheingp))