Our codebase has hundreds of derived Vars - How to make it REPL friendly?

The lookups are not that big a deal, adding minimal overhead.

(defn add [a b] (+ a b))

(with-out-str
  (time (dotimes [i 10000000]
          (add 1 1))))
=> "\"Elapsed time: 261.616819 msecs\"\n"

(with-out-str
  (time (dotimes [i 10000000]
          (#'add 1 1))))
=> "\"Elapsed time: 291.486518 msecs\"\n"

Custom macros need special care because they operate at compile time. If the macros change (especially if they do any kind of code rewriting), then any vars that reference the macro need to be reinitialised in order for the change to propagate.

1 Like