Re: Dynamic unquote ( , )?
- From: Eli Gottlieb <eligottlieb@xxxxxxxxx>
- Date: Tue, 07 Feb 2006 16:02:12 GMT
Ulrich Hobelmann wrote:
Ok, I rewrote my code to create code, or execute it, depending on the switch *execute-mode*. For that I changed one function to a macro, but with a problem:All I can think of is to construct the code programmatically instead of using backquote. Backquotes and commas are a convenience that the Lisp system (reader? Interpreter/Compiler?) expands into list-building code for you!
(defmacro emit-action (exp)
`(if *execute-mode*
,exp
(progn (collect-emit-buf) (push ',exp *actions*))))
; this expands to code that either executes exp or pushes its quotation to an action list.
; observe especially the ' quote, which causes whatever exp is to be inserted verbatim
(defun emit-stuff (val)
(emit-action (do-stuff-with val)))
Now the problem is that I don't want VAL to be pushed, i.e. I want something more like
(emit-action `(do-stuff-with ,val)) but then the emit-action macro won't execute that code, but expand to (if *bla* quoted-do-stuff-exp ...), so it will only *return* that expression, instead of executing it. Again I'm in a situation where I need to eval stuff :(
I'd like to be able to write the macro as:
`...(push `,exp *actions*)...
with a second quasiquote, and the call like (emit-action (do-stuff-with ,val)), but this doesn't work because the ` and , seem to be only read statically, i.e. the macro's second ` can't cause the , to unquote its argument.
Any ideas?
.
- References:
- Dynamic unquote ( , )?
- From: Ulrich Hobelmann
- Dynamic unquote ( , )?
- Prev by Date: Re: Interesting developments since "Beating the averages"?
- Next by Date: Re: Small Lisp to work with small operating system?
- Previous by thread: Re: Dynamic unquote ( , )?
- Next by thread: Re: Dynamic unquote ( , )?
- Index(es):
Relevant Pages
|