It seems the table needs to be created with #:phase -1. Since syntax-case uses a fender expression I added a begin in save-and-define, but it works either way (because free-id-table-set! returns a non-false value).
#lang racket (require (for-syntax syntax/id-table)) (define-for-syntax table (make-free-id-table #:phase -1)) (define-syntax (save-and-define stx) (syntax-case stx () [(_ ID) (begin (free-id-table-set! table #'ID 1) #'(define ID 1))])) (define-syntax (load stx) (syntax-case stx () [(_ ID2) (if (free-id-table-ref table #'ID2 #f) #''ok #''different)])) (module+ test (save-and-define a) (displayln (load a))) -- Jens Axel Søgaard 2014-04-03 7:26 GMT+02:00 Roman Klochkov <kalimeh...@mail.ru>: > #lang racket > (require (for-syntax syntax/id-table)) > > (define-for-syntax table (make-free-id-table)) > > (define-syntax (save-and-define stx) > (syntax-case stx () > [(_ ID) (free-id-table-set! table #'ID 1) #'(define ID 1)])) > > (define-syntax (load stx) > (syntax-case stx () > [(_ ID2) > (if (free-id-table-ref table #'ID2 #f) #''ok #''different)])) > > (module+ test > (save-and-define a) > (displayln (load a))) > > --------- > > Gives 'different. Expected 'ok > > P.S. If I change last sexp to > > ;(module+ test > (save-and-define a) > (displayln (load a)) > > then gives 'ok as expected. > > Please, help. > > -- > Roman Klochkov > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- -- Jens Axel Søgaard ____________________ Racket Users list: http://lists.racket-lang.org/users