Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

Currently, the docstring of with-redefs in CLJS reads:

([bindings & body])
  binding => var-symbol temp-value-expr

  Temporarily redefines vars while executing the body.  The
  temp-value-exprs will be evaluated and each resulting value will
  replace in parallel the root value of its var.  After the body is
  executed, the root values of all the vars will be set back to their
  old values. Useful for mocking out functions during testing.

It makes it seem as if it's perfectly fine to use it in a similar way you'd use the same macro in CLJ.
However, this comment by David Nolen says otherwise:

If you want something to be redefinable with with-redefs in production you need to mark those vars ^:dynamic.

1 Answer

0 votes

Just a side-note:

In JVM Clojure you ^:redef metadata is sufficient. See also the docs on direct linking: