On this page:
Version: 5.1.3

13 Finding Mutated Variables

Sam Tobin-Hochstadt <samth@ccs.neu.edu>

 (require unstable/mutated-vars)

This library is unstable; compatibility will not be maintained. See Unstable: May Change Without Warning for more information.

(find-mutated-vars stx [dict])  dict?
  stx : syntax?
  dict : dict? = (make-immutable-free-id-table)
Traverses stx, which should be module-level-form in the sense of the grammar for fully-expanded forms, and records all of the variables that are mutated. Each mutated variable is added to dict, mapped to #t. If dict is mutable, as determined by dict-mutable?, then the table is updated destructively. Otherwise, the table is updated functionally.


> (define t (find-mutated-vars #'(begin (set! var 'foo) 'bar)))
> (dict-ref t #'var #f)


> (dict-ref t #'other-var #f)


> (define tbl (make-free-id-table))
> (find-mutated-vars #'(begin (set! var 'foo) 'bar) tbl)


> (dict-ref tbl #'var #f)