On this page:
find-mutated-vars
Version: 5.2

14 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.

Examples:

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

#t

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

#f

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

#<mutable-free-id-table>

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

#t

}