|
|
|
|
|
by dasyatidprime
1873 days ago
|
|
Aha! I was half-wrong, but it's also horrible… (defclass tracer () ((actual :initarg :actual)))
(defun make-tracer (object)
(make-instance 'tracer :actual object))
;; But please don't.
(defmethod no-applicable-method :around (gf &rest args)
(if (typep (car args) 'tracer)
(let* ((tracer (car args))
(args* (cdr args))
(actual (slot-value tracer 'actual)))
(format t "Calling ~S on ~S" gf (cons actual args*))
(apply gf actual args*))
(apply #'call-next-method gf args)))
You can't do this with a real specialization on no-applicable-method, incidentally, because the first arg isn't special enough, it's just folded into the &rest. And that, I'm pretty sure, means this doesn't coexist with other uses of no-applicable-method properly… and you still can't do on-the-fly method names that aren't attached to a generic, and so on, but this does sort of account for the object forwarder case (and in fact you could extend it to allow tracers on more of the arguments!). It does, I expect, remain extremely unidiomatic by comparison. |
|