[racket] Syntax objects in prefab structures
The following program shows a difference between syntax objects stored
in prefab structures versus
transparent structures.
Is this a bug - or am I missing something about prefab structures?
#lang racket
(begin-for-syntax
(struct foo (baz) #:prefab)
(struct bar (baz) #:transparent)
(define structs '()))
(define-syntax (macro1 stx)
(set! structs (list (foo #'foox) (bar #'barx)))
#'(void))
(begin-for-syntax (displayln (list 1 structs)))
(macro1)
(begin-for-syntax (displayln (list 2 structs)))
(define-syntax (with stx)
(with-syntax ([s structs])
#'(begin
(begin-for-syntax
(set! structs 's))
(void))))
(with)
(begin-for-syntax (displayln (list 3 structs)))
The output is:
Welcome to DrRacket, version 6.1.1.4--2014-11-08(b7d2722d/d) [3m].
Language: racket; memory limit: 256 MB.
(1 ())
(2 (#s(foo .#<syntax:8:29 foox>) #(struct:bar .#<syntax:8:42 barx>)))
(3 (#s(foo foox) #(struct:bar .#<syntax:8:42 barx>)))
(1 ())
(2 ())
(3 (#s(foo foox) #(struct:bar .#<syntax:8:42 barx>)))
(1 ())
(2 ())
(3 (#s(foo foox) #(struct:bar .#<syntax:8:42 barx>)))
The syntax object in the prefab structure turned into a symbol !
--
Jens Axel Søgaard