chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] help with implicit renaming macro


From: Peter Bex
Subject: Re: [Chicken-users] help with implicit renaming macro
Date: Mon, 11 Nov 2013 21:36:48 +0100
User-agent: Mutt/1.4.2.3i

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]