<span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">The third cond ((member (car code) macros)<div class="im" style="color: rgb(80, 0, 80); "><br> (%expand-macros (macroexpand-1 code)))</div>
<div>expands code when using macroexpand-1 and then recursively call</div><div>%expand-macros to expand any macro in the parameter macros</div><div><br></div><div>I was not aware of macroexpand-all: is there a way to tell which </div>
<div>macros to expand (i do want to expand only selected macros so that</div><div>the generated code do not become very large)</div><div><br></div><div>Kind regards</div><div>Taoufik</div></span><br><div class="gmail_quote">
On Sat, Dec 11, 2010 at 9:25 PM, <span dir="ltr"><<a href="mailto:rm@tuxteam.de">rm@tuxteam.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sat, Dec 11, 2010 at 07:03:07PM +0100, Taoufik Dachraoui wrote:<br>
> Hi<br>
><br>
> I had a bug in my compiler generator and found it difficult to trace the<br>
> root of the error<br>
> I could not find something like macroexpand-1 but expands all macros<br>
<br>
</div>You mean like macroexpand-all ?<br>
<div class="im"><br>
<br>
> I wrote the following macro to do that and would like to share it (any<br>
> comments are welcome)<br>
><br>
> ? (defun expand-macros (code macros)<br>
> (labels ((%expand-macros (code)<br>
> (cond<br>
> ((null code) nil)<br>
> ((atom code) code)<br>
> ((member (car code) macros)<br>
> (%expand-macros (macroexpand-1 code)))<br>
> (t<br>
> (loop for c in code<br>
> collect (%expand-macros c))))))<br>
> (pprint (%expand-macros (macroexpand-1 code)))))<br>
> EXPAND-MACROS<br>
<br>
</div>But this definition doesn't match your own description.<br>
And the third cond expression seems to be buggy: a macro call in the<br>
macro's arguments doesn't get expanded.<br>
<br>
<br>
Cheers, Ralf Mattes<br>
<div><div></div><div class="h5"><br>
> ? (expand-macros '(gen-guido-compiler) '(destructuring-match-specials<br>
> cond-match-specials))<br>
><br>
> (DEFUN COMPILE/0 (EXPR &OPTIONAL (GENV (MAKE-HASH-TABLE)))<br>
> (DELCARE (SPECIAL X) (SPECIAL L))<br>
> (LET ((#:G28589<br>
> (BLOCK NIL<br>
> (LET* ((#:G28590 EXPR)<br>
> (N<br>
> (IF (AND (ATOM #:G28590)<br>
> (TYPEP #:G28590 '(UNSIGNED-BYTE 32)))<br>
> #:G28590<br>
> (RETURN-FROM NIL NIL))))<br>
> (DECLARE (SPECIAL N))<br>
> (PROGN (EMIT 17 *OPCODE-SIZE*) (EMIT N *WORD-SIZE*))))))<br>
> (IF (NOT (NULL #:G28589))<br>
> (PROGN (FORMAT T<br>
> "expression ~A matched ~A~%"<br>
> EXPR<br>
> '(:TYPE N '(UNSIGNED-BYTE 32)))<br>
> #:G28589)<br>
> (LET ((#:G28589<br>
> (LET ((#:G28591<br>
> (BLOCK NIL<br>
> (LET* ((#:G28592 EXPR)<br>
> (X<br>
> (IF (AND (ATOM #:G28592)<br>
> (TYPEP #:G28592 'SYMBOL))<br>
> #:G28592<br>
> (RETURN-FROM NIL NIL))))<br>
> (DECLARE (SPECIAL X))<br>
> (PROGN (EMIT 8 *OPCODE-SIZE*)<br>
> (EMIT (IFNULL. (CAR (GETHASH X GENV)) 0)<br>
> *WORD-SIZE*)<br>
> (EMIT 0 *WORD-SIZE*)<br>
> (EMIT 19 *OPCODE-SIZE*))))))<br>
> ........<br>
><br>
> Kind regatds<br>
> Taoufik<br>
<br>
</div></div>> _______________________________________________<br>
> Openmcl-devel mailing list<br>
> <a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>
> <a href="http://clozure.com/mailman/listinfo/openmcl-devel" target="_blank">http://clozure.com/mailman/listinfo/openmcl-devel</a><br>
<br>
</blockquote></div><br>