Re: Nonstandard method combinations?
- From: Michal Krupka <kokoml2@xxxxxxx>
- Date: Sat, 28 Oct 2006 18:52:56 +0200
BTW, I've tried the code on LispWorks, SBCL, and Allegro, and only LispWorks does not lead to error after executing (upgrade-config-file 2). The error is "More than one method of type METHODS with the same specializers." Is there an error in my code?
Michal
On 2006-10-28 16:11:14 +0200, Michal Krupka <kokoml2@xxxxxxx> said:
(define-method-combination sort-and-cut ()
((methods positive-integer-qualifier-p))
(:arguments from)
(flet ((met-stage (met)
(first (method-qualifiers met))))
`(progn ,@(mapcar #'(lambda (method)
`(when (>= ,(met-stage method) ,from)
(call-method ,method)))
(stable-sort methods #'< :key #'met-stage))
nil)))
(defun positive-integer-qualifier-p (method-qualifiers)
(and (= (length method-qualifiers) 1)
(typep (first method-qualifiers) '(integer 0 *))))
(defgeneric upgrade-config-file (stage)
(:method-combination sort-and-cut))
(defmethod upgrade-config-file 0 (stage)
(print "Upgraded from version 0 to 1"))
(defmethod upgrade-config-file 1 (stage)
(print "Upgraded from version 1 to 2"))
(defmethod upgrade-config-file 2 (stage)
(print "Upgraded from version 2 to 3"))
(defmethod upgrade-config-file 3 (stage)
(print "Upgraded from version 3 to 4"))
(upgrade-config-file 2)
.
- Follow-Ups:
- Re: Nonstandard method combinations?
- From: Christophe Rhodes
- Re: Nonstandard method combinations?
- References:
- Nonstandard method combinations?
- From: Michal Krupka
- Nonstandard method combinations?
- Prev by Date: Re: Using lisp to generate .net business applications
- Next by Date: Re: Nonstandard method combinations?
- Previous by thread: Re: Nonstandard method combinations?
- Next by thread: Re: Nonstandard method combinations?
- Index(es):