Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
deterministic gentemp
(def ^:dynamic *gentemp-counters*)
(defn new-gentemp-counters [] {})
(defn next-name [name]
(let [c (get *gentemp-counters* name 0)]
(set! *gentemp-counters* (assoc *gentemp-counters* name (inc c)))
(str name "-" c)))
(defmacro with-reset-ids [& body]
`(binding [*gentemp-counters* (new-gentemp-counters)]

This comment has been minimized.

Copy link
Owner Author

commented Apr 17, 2012


> (with-reset-ids (next-name "foo")
                        (next-name "foo"))
> (with-reset-ids (next-name "foo")
                        (next-name "foo")
                        (next-name "foo"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.