[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need help defining desfstruct within non-top-level macro call



I am trying to write a macro that is called from within a function
definition, but that includes the definition of a defstruct as a side
effect of its expansion.

First try is:
(defmacro foo (struct-def) &body body
	`(progn
		(defstruct foo-struct ,@struct-def)
		,@body))

However, the macro is used within a defun:

(defun bar (parm)
	(mumble ...)
	(foo (a b c)
	     (something interesting)))
	
which  expands into

(defun bar (parm)
	(mumble ...)
	(progn
	    (defstruct foo-struct a b c)
	    (something interesting)))

Now I really want the defstruct to be outside the defun.

What I want to do is evaluate the defstruct part at compile and load
time, not execution. But eval-when is only allowed at the top level. How
do I move the defstruct to the appropriate place?


drstrip@cs.sandia.gov