[closer-devel] Contextl patch: make ensure-layered-method work with function objects as well as names.

Drew Crampsie drewc at tech.coop
Sat Sep 27 21:05:46 UTC 2008


Hello,

In lol i use ensure-layered-method directly on generic functions. I've
been using this modified version of ensure-layered-method  and thought
i'd try and sneak it in :).

(defun ensure-layered-method
       (layered-function-designator
        lambda-expression
        &key
	(layered-function
	 (if (functionp layered-function-designator)
	     layered-function-designator
	     (fdefinition (lf-definer-name layered-function-designator))))
	        #-(or allegro clisp cmu ecl mcl openmcl)
        (method-class
         (generic-function-method-class
          layered-function))
        (in-layer 't)
        (qualifiers ())
        (lambda-list (cadr lambda-expression))
        (specializers (required-args lambda-list (constantly (find-class 't)))))
  (let ((layer-arg (gensym "LAYER-ARG-")))
    (destructuring-bind
        (lambda (&rest args) &body body)
        lambda-expression
      (unless (eq lambda 'lambda)
        (error "Incorrect lambda expression: ~S." lambda-expression))
      (ensure-method layered-function
                     `(lambda (,layer-arg , at args) , at body)
                     #-(or allegro clisp cmu ecl mcl openmcl) :method-class
                     #-(or allegro clisp cmu ecl mcl openmcl) method-class
                     :qualifiers qualifiers
                     :lambda-list `(,layer-arg , at lambda-list)
                     :specializers (cons (find-layer-class in-layer)
specializers)))))

Cheers,

drewc



More information about the closer-devel mailing list