MOP/Macroexpansion
- From: "Andreas Thiele" <nospam@xxxxxxxxxx>
- Date: Sun, 29 May 2005 14:02:50 +0200
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
.
- Follow-Ups:
- Re: MOP/Macroexpansion
- From: Andreas Thiele
- Re: MOP/Macroexpansion
- From: Coby Beck
- Re: MOP/Macroexpansion
- From: Pascal Costanza
- Re: MOP/Macroexpansion
- Prev by Date: Re: my first Lisp code...comments welcome
- Next by Date: Re: my first Lisp code...comments welcome
- Previous by thread: Macros and symbols across packages
- Next by thread: Re: MOP/Macroexpansion
- Index(es):