chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] combining syntax-rules and er/ir-macro


From: .alyn.post.
Subject: [Chicken-users] combining syntax-rules and er/ir-macro
Date: Wed, 29 Jan 2014 18:07:20 -0700

I'm working on a macro, |enum|, that accepts a prefix and a set of
values, that expand in to a basic symbolic enumeration:

  (enum my foo bar)
  =>
  (define my '(foo bar))
  (define my-foo 'foo)
  (define my-bar 'bar)

The reason for the above is immaterial, I really need help with the
error I'm seeing trying to implement it.  I am using a combination
of syntax-rules and er/ir macros, and I'm getting an error message
I don't understand (warning, untested code):

  <++> file.scm
  (define-syntax $%map
    (syntax-rules ()
      ((_ fn () (r ...)) (r ...))
      ((_ fn (x y ...) (r ...)) ($%map fn (y ...) (r ... (fn x))))))

  ; (map foo x y z) => ((foo x) (foo y) (foo z))
  ;
  (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 ,@(%map quote (cdr form)))))))

  (enum my foo bar)
  (pretty-print `(,my ,my-foo ,my-bar))
  <-->

  $ csi -n file.scm
  Error: during expansion of (enum ...) - unbound variable: %map

Why is %map not visible inside enum?

-a
--
my personal website: http://c0redump.org/



reply via email to

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