Re: Problem with Macro expanding to defmethod



Kalle Olavi Niemitalo wrote:

All this mess could perhaps be avoided with the MOP. I recall it
generates a "method function" for each method, and the method
function receives the whole argument list as well as a list of
next methods. So if you could hook up into how that function is
generated, you could snatch the argument list before it is
chopped up into separate parameters. I don't know how this might
best be accomplished in practice.

You could implement a method class, roughly like this:

(defclass raising-method (standard-method)
())

(defmethod initialize-instance :around
((method raising-method) &rest initargs &key function)
(declare (dynamic-extent initargs))
(apply #'call-next-method method
:function (lambda (args &rest other-args)
(declare (dynamic-extent other-args))
(raise-method
(method-generic-function method)
args)
(apply function args other-args))
initargs))

Many MOP implementations don't adhere to the MOP spec here, though.


Pascal

--
3rd European Lisp Workshop
July 3-4 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/
.