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/

_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to