Wrong macro expansion order

Issue #285 resolved
Takashi Kato repo owner created an issue

This should print bar but instead it raises an error

(library (foo)
    (export define-define)
    (import (rnrs))
(define-syntax define-define
  (lambda (x)
    (syntax-case x ()
      ((_ name)
       #'(define-syntax name
       (lambda (xx)
         (syntax-case xx ()
           ((_)
        #'(syntax-rules ()
            ((_) (begin (display 'name) (newline))))))))))))

)

(library (bar)
    (export definer)
    (import (rnrs)
        (foo))
(define-define bar)
(define-syntax definer (bar))
)

(import (bar))

(definer)

Comments (2)

  1. Takashi Kato reporter

    The problem is that we first expand define-syntax then expand macro, however in this case, define-define creates a macro, which will be expanded after define-syntax is processed

  2. Log in to comment