On Mon, Nov 11, 2013 at 01:22:40PM -0701, Alan Post wrote:
> I'd like to rewrite this macro as an implicit renaming
> macro, which seems to require that I traverse form and
> insert (inject arg1) wherever I find arg1, and to do
> the same for arg2.

Hi Alan,

Actually, you only need to inject the args where they
are introduced.  This will cause them to be bound
unhygienically, which means they'll capture any local
variables with that same literal name.

So unless I'm completely misunderstanding what you're
trying to do, this will suffice:

(define-syntax do-output 
  (ir-macro-transformer
    (lambda (e i c)
      `(lambda (#!key ,(i 'arg1) ,(i 'arg2))
         (list ,@(cdr e))))))

> I do not otherwise need to transform the symbolic
> expression bound to output.  Is there some idiomatic
> way to traverse a tree and perform a set of replacement
> operations on matching leaves?  

SSAX has "foldts" which can fold over trees, but I think
it's overkill to load an XML library just to transform your
macros :)

Finally, you might want to take a look at some of Juergen Lorenz's
eggs, they provide some tools to deal with low-level macros a bit
more conveniently.

Cheers,
Peter
-- 
http://www.more-magic.net

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to