[plt-scheme] Compile and Run-Time Phase question
(define-syntax identifier-syntax
(lambda (x)
(syntax-case x ()
((_ e)
(syntax
(lambda (x)
(syntax-case x ()
(id
(identifier? (syntax id))
(syntax e))
((id x (... ...))
(identifier? (syntax id))
(syntax (e x (... ...)))))))))))
(let ((x 0))
(define-syntax x++
(identifier-syntax
(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
error:
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-
syntax?