[plt-scheme] Compile and Run-Time Phase question

From: Adrian Patino (apatinoii at gmail.com)
Date: Wed Jan 21 17:18:11 EST 2009

(define-syntax identifier-syntax
  (lambda (x)
    (syntax-case x ()
      ((_ e)
         (lambda (x)
           (syntax-case x ()
              (identifier? (syntax id))
              (syntax e))
             ((id x (... ...))
              (identifier? (syntax id))
              (syntax (e x (... ...)))))))))))

(let ((x 0))
  (define-syntax x++
      (let ((t x)) (set! x (+ t 1)) t)))
  (let ((a x++))
    (list a x)))

returns with error:
expand: unbound identifier in module (in the transformer environment,
which does not include the macro definition that is visible to run-
time expressions)

using (define-for-syntax identifier-syntax ...) insteads returns with
compile: identifier used out of context in: x
referring to the x in the let expression.

Why is it out of context?
Also, I noticed that other scheme implementations allow this code to
work, such as ypsilon. What are the benefits of using define-for-

Posted on the users mailing list.