Re: Dynamic unquote ( , )?
- From: Ulrich Hobelmann <u.hobelmann@xxxxxx>
- Date: Tue, 07 Feb 2006 20:06:01 +0100
Kaz Kylheku wrote:
but the LIST is not evaluated, since this is a macro. So what ends up
happening is that this expands to the code:
(if *execute-mode*
(list 'do-stuff-with val)
(progn (collect-emit-buf) (push '(list 'do-stuff-with val)
*actions*))
In excute mode, the (LIST 'DO-STUFF-WITH VAL) doesn't do the right
thing now. Although it can correctly resolve the value of VAL from the
surrounding lexical environment, all it does is compute the expression
and throw it away.
In execute mode it creates a list, instead of evaluating the expression, yes.
In delayed mode, the expression (LIST 'DO-STUFF-WITH VAL) is evaled,
but it can't resolve the correct value of VAL.
No, in delayed mode it pushes a list of the symbol 'do-stuff-with, along with the *value* of val, at least until I modified the code :)
Later, the macro simply fetches all those Lisp expressions and lets the top-level-macro expand to all that code. Then the code can be compiled into a function.
You want this code to come out of the macro:
(if *execute-mode*
(do-stuff-with val)
(progn
(collect-emit-buf)
(push (lambda () (do-stuff-with val)) *actions*)))
build this out of (EMIT-ACTION (DO-STUFF-WITH-VAL)).From this pattern, it should be obvious how to write the macro which
So *ACTIONS* isn't a list containing fragments of source code. It's a
list of first-class funtions (which are compiled if the places that
generate them are compiled!)
But then what would the macro expand to? Right now it outputs a list of all the collected statements to compile, and execute at runtime. But a macro can't return *functions*, can it?
You call these first class functions using FUNCALL, rather than EVAL.
Yes... still thinking...
The problem is to reconcile the old macro code with the new mode of simply running the code.
--
Suffering from Gates-induced brain leakage...
.
- Follow-Ups:
- Re: Dynamic unquote ( , )?
- From: Kaz Kylheku
- Re: Dynamic unquote ( , )?
- References:
- Dynamic unquote ( , )?
- From: Ulrich Hobelmann
- Re: Dynamic unquote ( , )?
- From: Kaz Kylheku
- Dynamic unquote ( , )?
- Prev by Date: Re: Stylistic question on control transfer (return vs. throw)
- Next by Date: Re: Cross-lisp questions and my #lisp experience
- Previous by thread: Re: Dynamic unquote ( , )?
- Next by thread: Re: Dynamic unquote ( , )?
- Index(es):
Relevant Pages
|