Skip to content

Instantly share code, notes, and snippets.

@samth
Last active December 28, 2015 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samth/7558673 to your computer and use it in GitHub Desktop.
Save samth/7558673 to your computer and use it in GitHub Desktop.
> (define x 1)
> (set! x 2)
> (set! x 3)
> global
#<mutable-free-id-table>
> (for/list ([(k v) (in-dict global)]) (list k v))
'((.#<syntax:4:8 x> 3))
#lang racket
(require syntax/id-table (only-in racket [set! #%set!]))
(define global (make-free-id-table))
(define-syntax-rule (location-of id) #'id)
(define-syntax-rule (set! id expr)
(let ([v expr])
(dict-set! global (location-of id) v)
(#%set! id v)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment