Internal definition should be evaluated as letrec*

Create issue
Issue #106 resolved
Takashi Kato repo owner created an issue

This should print foo

#!r6rs
(import (rnrs))

(define-syntax foo
  (lambda (x)
    (syntax-case x ()
      ((k name)
       #'(begin
           (define the-name 'foo)
           (define-syntax name
             (lambda (xx)
               (syntax-case xx (:foo)
                 ((_ :foo) #'the-name)))))))))

(define-syntax bar
  (lambda (x)
    (syntax-case x ()
      ((k name foo?)
       #'(begin
           (define the-name 'bar)
           (define-syntax name
             (lambda (xx)
               (syntax-case xx (:foo :bar)
                 ((_ :foo) #'(foo? :foo))
                 ((_ :bar) #'the-name)))))))))

(let ()
  (foo foo1)
  (bar bar1 foo1)

  (display (bar1 :foo)) (newline)
)

But raises an error.

This because binding creation of internal definitions are postponed until it's compiled however the macro expansion needs to know which bindings are available in this case.

Comments (1)

  1. Log in to comment