[gambit-list] macro-expansion bug (?)

dev null doonboggle at gmail.com
Tue Feb 22 09:25:24 EST 2005


Hi,

The following works in chicken and bigloo, but fails on gambit  4.0b12:

---------------------------------------------------------------------------------------
(define-macro (build-funcs)
  (define any '(list? number? string?))

  (define funcnames
    `((is-string string?)
      (is-number number?)
      (is-list list?)
      (is-any ,any)))
  (define (build desc)
    (let ((name (car desc))
          (tests (if (list? (cadr desc))
                     (cadr desc)
                     (cdr desc))))
      `(define ,name
         (lambda (o)
           (or ,@(map (lambda (x)
                        (list x 'o))
                      tests))))))
  `(begin ,@(map build funcnames)))

(pp (lambda () (build-funcs) #t))
(build-funcs)

(is-any "dd")
---------------------------------------------------------------------------------------

It seems that the reference to the `any' variable is unbound inside
`funcnames'.  If you move the definition of `any' outside of the body
of `build-funcs', everything works fine.

Not sure if this is a bug, or a misunderstanding on my part.

Best Regards,

Ben


More information about the Gambit-list mailing list