[racket-dev] splicing-syntax-parameterize and syntax-parameter-value
Simpler example:
(require racket/splicing racket/stxparam)
(define-syntax-parameter f #f)
(define x 0)
;; 0
(syntax-parameterize ([f (make-rename-transformer #'x)]) (splicing-syntax-parameterize ([f (syntax-parameter-value #'f)]) f))
;; 0
(splicing-syntax-parameterize ([f (make-rename-transformer #'x)]) (syntax-parameterize ([f (syntax-parameter-value #'f)]) f))
;; error
> (splicing-syntax-parameterize ([f (make-rename-transformer #'x)]) (splicing-syntax-parameterize ([f (syntax-parameter-value #'f)]) f))
stdin::334: f: bad syntax
in: f
context...:
/home/ianj/racket/collects/racket/splicing.rkt:224:0
/home/ianj/racket/collects/racket/splicing.rkt:177:0
/home/ianj/racket/collects/racket/splicing.rkt:224:0
/home/ianj/racket/collects/racket/splicing.rkt:177:0
/home/ianj/racket/collects/racket/private/misc.rkt:87:7
-Ian
----- Original Message -----
From: "J. Ian Johnson" <ianj at ccs.neu.edu>
To: "dev" <dev at racket-lang.org>
Sent: Thursday, November 29, 2012 4:01:09 PM GMT -05:00 US/Canada Eastern
Subject: [racket-dev] splicing-syntax-parameterize and syntax-parameter-value
(require racket/stxparam racket/splicing)
(define-syntax-parameter f #f)
(splicing-syntax-parameterize ([f #t])
(begin-for-syntax (printf "~a~%" (syntax-parameter-value #'f)))
(void))
This prints #f.
If I instead add a macro indirection
(define-syntax (blah stx) (syntax-case stx () [(_ f) (printf "~a~%" (syntax-parameter-value #'f)) #'(void)]))
Then
(splicing-syntax-parameterize ([f #t])
(blah f)
(void))
prints #t
This is messing up some of my syntax parameters that build their definitions from the existing value in the parameter. Why does the first program have this behavior? This feels bug-like to me.
-Ian
_________________________
Racket Developers list:
http://lists.racket-lang.org/dev