MOP/Macroexpansion



Hi,

the following code snippet works in my application if def-class is used at
top-level:

(defmacro def-methods (name)
`(progn ,@(class-methods name)))

(defmacro def-class (name parents &body body)
`(progn
(defclass ,name ,(if parents parents '(db-root))
,@(transform-source name body)
(:metaclass db-class))
(def-methods ,name)))

class-methods computes a list of defmethod forms and needs to call
find-class on the created class. Thus defclass needs to be executed before
def-methods is expanded. This does not work, if I use def-class within a
function (not at top-level). In this case - I think - everything gets
expanded and thus def-methods gets expanded before defclass is executed.
class-method will fail on calling find-class of course.

At the moment I am more astonished that the macro works at top-level.

Can anybody give a hint?
Any suggestions how I can solve the problem?

Andreas


.