Thank you Evan, that helps explain the error message I was seeing. When I make your proposed changes, I get the following:
<++> my-file.scm (begin-for-syntax (define-syntax $%map (syntax-rules () ((_ fn () (r ...)) (r ...)) ((_ fn (x y ...) (r ...)) ($%map fn (y ...) (r ... (fn x)))))) (define-syntax %map (syntax-rules () ((_ fn l ...) ($%map fn (l ...) ()))))) (define-syntax enum (ir-macro-transformer (lambda (form inject compare?) `(define-values (,(cadr form) ,@(map (lambda (x) (symbol-append (cadr form) '- x)) (cddr form))) (values ,@((inject '%map) (inject 'quote) (cdr form))))))) (enum my foo bar) (pretty-print `(,my ,my-foo ,my-bar)) <--> $ csi -n my-file.scm Error: during expansion of (enum ...) - call of non-procedure: %map128 I might assume the problem here is that %map isn't a procedure, it's syntax, and that the symbol is being properly injected, but then how do I can a macro from a macro? I'm not even certain I'm diagnosing the problem correctly. -a On Thu, Jan 30, 2014 at 03:16:57PM +1300, Evan Hanson wrote: > Hi Alyn, > > On 2014-01-29 18:07, .alyn.post. wrote: > > Why is %map not visible inside enum? > > In order to make `%map` available to the enum transformer, it needs to > be defined at expansion time, e.g. (this is one way, there may be others): > > (begin-for-syntax > (define-syntax %map > (syntax.rules () ...))) > > Also note that because `enum` is an ir transformer, the form provided to > it will already have been renamed, so as it stands it will most likely > define something like "my-foo123" rather than "my-foo" -- you'll > probably have to `inject` those parts of the form in order to have the > correct identifiers bound as a result </possibly unwelcome observation>. > > Cheers, > > Evan > > _______________________________________________ > Chicken-users mailing list > Chicken-users@nongnu.org > https://lists.nongnu.org/mailman/listinfo/chicken-users -- my personal website: http://c0redump.org/ _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users