I'm always interested in the stuff Zach Tellman does, though I don't always
understand it. I'm curious about this bit:
(memoize (fn [_#] (gensym "node"))
How is that different than
(gensym "node")
I only see with-gensyms called once, so I assume the goal is to have
dynamic bindings set up for that block of code.
(defmacro ^:private with-gensyms
"Makes sure the mapping of node and clusters onto identifiers is
consistent within its scope."
[& body]
`(binding [*node->id* (or *node->id* (memoize (fn [_#] (gensym "node"))))
*cluster->id* (or *cluster->id* (memoize (fn [_#] (gensym
"cluster"))))]
~@body))
https://github.com/ztellman/rhizome/blob/1bca773540a0bd244650293d76374b7f0472025e/src/rhizome/dot.clj
The "or" should ensure that the function is only called once, so why is the
memoize needed? When would the function be called a second time, at which
point the memoized response could be returned?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.