Hi everybody,
Here's some behavior I see on SBCL as well as LispWorks, so I'm assuming for now they're right in doing so. My question would be why they are.
I start with the following code which I compile and load:
;;;;;;;;;;;;;;;;;;;;;;;;
(defvar *current-qualifiers* '(:a :b :c))
(define-method-combination test () ((methods *)) (let ((selected-methods (loop for method in methods when (intersection (method-qualifiers method) *current-qualifiers*) collect method))) `(call-method ,(first selected-methods) ,(rest selected-methods))))
(defgeneric foo (thing) (:method-combination test)) (defmethod foo :a (thing) '(:red)) (defmethod foo :b (thing) '(:blue))
;;;;;;;;;;;;;;;;;;;;;;;;;;
Now, in the REPL I do the following:
CL-USER> (foo 42) (:BLUE) CL-USER> (setq *current-qualifiers* '(:a :c)) (:A :C) CL-USER> (foo 42) (:BLUE)
I almost expected this. The effective method obviously isn't computed anew but was cached. But even if I now re-evaluate the DEFINE-METHOD-COMBINATION form, (FOO 42) will still return (:BLUE). Only if I re-evaluate the DEFGENERIC form will the return value change to (:RED).
My question is if the standard somewhere allows this caching to happen. That would for example mean that any kind of "dynamic method combination" (for example based on the time of the day, just for grins) is impossible.
Or am I missing something and my interpretation is wrong?
Thanks, Edi.