On Mon, Nov 11, 2013 at 09:36:48PM +0100, Peter Bex wrote: > 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. >
Aha, I missed the quote to the inject parameter, got an error about arg1, and assumed it was happening during expansion to report an unbound variable. pebkac. This does indeed work, fantastic. Really stellar feature, ir-macros. I have the most experience with defmacro, and it took me some time to come to terms with define-syntax/syntax-rules, though the vast majority of my macros fit easily and comfortably in that rubric. This was the first time in a long while I've wanted to do something more than simple transformation. I appreciate your guidance here! -a -- my personal website: http://c0redump.org/ _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users