',type ',operator ',identity-with-one-arg ',documentation)))
(defun load-short-defcombin (type operator ioa doc)
- (let* ((truename *load-truename*)
+ (let* ((pathname *load-pathname*)
(specializers
(list (find-class 'generic-function)
(intern-eql-specializer type)
:qualifiers ()
:specializers specializers
:lambda-list '(generic-function type options)
- :function #'(lambda(args nms &rest cm-args)
- (declare (ignore nms cm-args))
- (apply
- #'(lambda (gf type options)
- (declare (ignore gf))
- (do-short-method-combination
- type options operator ioa new-method doc))
- args))
- :definition-source `((define-method-combination ,type) ,truename)))
+ :function (lambda (args nms &rest cm-args)
+ (declare (ignore nms cm-args))
+ (apply
+ (lambda (gf type options)
+ (declare (ignore gf))
+ (short-combine-methods
+ type options operator ioa new-method doc))
+ args))
+ :definition-source `((define-method-combination ,type) ,pathname)))
(when old-method
(remove-method #'find-method-combination old-method))
- (add-method #'find-method-combination new-method)))
+ (add-method #'find-method-combination new-method)
+ type))
-(defun do-short-method-combination (type options operator ioa method doc)
+(defun short-combine-methods (type options operator ioa method doc)
(cond ((null options) (setq options '(:most-specific-first)))
((equal options '(:most-specific-first)))
((equal options '(:most-specific-last)))
(let ((type (method-combination-type combin))
(operator (short-combination-operator combin))
(ioa (short-combination-identity-with-one-argument combin))
+ (order (car (method-combination-options combin)))
(around ())
(primary ()))
(dolist (m applicable-methods)
(push m primary))
(t
(lose m "has an illegal qualifier"))))))
- (setq around (nreverse around)
- primary (nreverse primary))
+ (setq around (nreverse around))
+ (ecase order
+ (:most-specific-last) ; nothing to be done, already in correct order
+ (:most-specific-first
+ (setq primary (nreverse primary))))
(let ((main-method
(if (and (null (cdr primary))
(not (null ioa)))
`(call-method ,(car primary) ())
- `(,operator ,@(mapcar #'(lambda (m) `(call-method ,m ()))
+ `(,operator ,@(mapcar (lambda (m) `(call-method ,m ()))
primary)))))
(cond ((null primary)
`(error "No ~S methods for the generic function ~S."
(lambda-list (caddr form))
(method-group-specifiers (cadddr form))
(body (cddddr form))
- (arguments-option ())
+ (args-option ())
(gf-var nil))
(when (and (consp (car body)) (eq (caar body) :arguments))
- (setq arguments-option (cdr (pop body))))
+ (setq args-option (cdr (pop body))))
(when (and (consp (car body)) (eq (caar body) :generic-function))
(setq gf-var (cadr (pop body))))
(multiple-value-bind (documentation function)
(make-long-method-combination-function
- type lambda-list method-group-specifiers arguments-option gf-var
+ type lambda-list method-group-specifiers args-option gf-var
body)
`(load-long-defcombin ',type ',documentation #',function))))
:qualifiers ()
:specializers specializers
:lambda-list '(generic-function type options)
- :function #'(lambda (args nms &rest cm-args)
- (declare (ignore nms cm-args))
- (apply
- #'(lambda (generic-function type options)
- (declare (ignore generic-function options))
- (make-instance 'long-method-combination
- :type type
- :documentation doc))
- args))
- :definition-source `((define-method-combination ,type)
- ,*load-truename*))))
+ :function (lambda (args nms &rest cm-args)
+ (declare (ignore nms cm-args))
+ (apply
+ (lambda (generic-function type options)
+ (declare (ignore generic-function))
+ (make-instance 'long-method-combination
+ :type type
+ :options options
+ :documentation doc))
+ args))
+ :definition-source `((define-method-combination ,type)
+ ,*load-pathname*))))
(setf (gethash type *long-method-combination-functions*) function)
(when old-method (remove-method #'find-method-combination old-method))
- (add-method #'find-method-combination new-method)))
+ (add-method #'find-method-combination new-method)
+ type))
(defmethod compute-effective-method ((generic-function generic-function)
(combin long-method-combination)
applicable-methods))
(defun make-long-method-combination-function
- (type ll method-group-specifiers arguments-option gf-var body)
- ;;(declare (values documentation function))
+ (type ll method-group-specifiers args-option gf-var body)
(declare (ignore type))
- (multiple-value-bind (documentation declarations real-body)
- (extract-declarations body)
+ (multiple-value-bind (real-body declarations documentation)
+ ;; (Note that PARSE-BODY ignores its second arg ENVIRONMENT.)
+ (parse-body body nil)
(let ((wrapped-body
(wrap-method-group-specifier-bindings method-group-specifiers
(when gf-var
(push `(,gf-var .generic-function.) (cadr wrapped-body)))
- (when arguments-option
- (setq wrapped-body (deal-with-arguments-option wrapped-body
- arguments-option)))
+ (when args-option
+ (setq wrapped-body (deal-with-args-option wrapped-body args-option)))
(when ll
(setq wrapped-body
(push name names)
(push specializer-cache specializer-caches)
(push `((or ,@tests)
- (if (equal ,specializer-cache .specializers.)
- (return-from .long-method-combination-function.
- '(error "More than one method of type ~S ~
+ (if (and (equal ,specializer-cache .specializers.)
+ (not (null .specializers.)))
+ (return-from .long-method-combination-function.
+ '(error "More than one method of type ~S ~
with the same specializers."
- ',name))
- (setq ,specializer-cache .specializers.))
- (push .method. ,name))
- cond-clauses)
+ ',name))
+ (setq ,specializer-cache .specializers.))
+ (push .method. ,name))
+ cond-clauses)
(when required
(push `(when (null ,name)
(return-from .long-method-combination-function.
(dolist (.method. .applicable-methods.)
(let ((.qualifiers. (method-qualifiers .method.))
(.specializers. (method-specializers .method.)))
- (progn .qualifiers. .specializers.)
+ (declare (ignorable .qualifiers. .specializers.))
(cond ,@(nreverse cond-clauses))))
,@(nreverse required-checks)
,@(nreverse order-cleanups)
;;;
;;; At compute-effective-method time, the symbols in the :arguments
;;; option are bound to the symbols in the intercept lambda list.
-(defun deal-with-arguments-option (wrapped-body arguments-option)
+(defun deal-with-args-option (wrapped-body args-option)
(let* ((intercept-lambda-list
(let (collect)
- (dolist (arg arguments-option)
+ (dolist (arg args-option)
(if (memq arg lambda-list-keywords)
(push arg collect)
(push (gensym) collect)))
(nreverse collect)))
(intercept-rebindings
- (loop for arg in arguments-option
+ (loop for arg in args-option
for int in intercept-lambda-list
unless (memq arg lambda-list-keywords)
collect `(,arg ',int))))