Zuriar
Zuriar

Reputation: 11744

Is it possible to exclude functions/name-spaces from :reload on the Repl?

I have two functions which do IO in a dosync. Therefore when I do a

(require 'my.namespace :reload)

I get:

CompilerException java.lang.IllegalStateException: I/O in transaction, compiling:

Is there a way to exclude the reloading of these two functions, or a whole namespace?

Upvotes: 2

Views: 99

Answers (1)

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91554

If you have top level forms that have side effects (such as reading or writing things) you can protect them from being reloaded with the defonce macro:

(defonce launcher (fire-the-missiles))

This way if launcher is already defined, the form that defines it won't be re-evaluated. It's something of a code smell to have too many side effects in top level forms because when you do want to reload them it's more difficult.

Upvotes: 6

Related Questions