Apologies are not the full answer. I haven't figured it all out yet.
*allow-unresolved-vars* is defined in RT.java :
final static Var ALLOW_UNRESOLVED_VARS = Var.intern(CLOJURE_NS, Symbol.intern("*allow-unresolved-vars*"), F).setDynamic();
and used in Compiler.java :
if(o == null) { if(RT.booleanCast(RT.ALLOW_UNRESOLVED_VARS.deref())) { return sym; } else { throw Util.runtimeException("Unable to resolve symbol: " + sym + " in this context"); } }
Thus, its use here is to decide whether an exception should be thrown immediately when an unresolved symbol occurs.
You can handle it:
myns.core=> (ns clojure.core) nil clojure.core=> oops! CompilerException java.lang.RuntimeException: Unable to resolve symbol: oops! in this context, compiling:(/tmp/form-init1596111142512149454.clj:1:884) clojure.core=> (defn q [] (oops!)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: oops! in this context, compiling:(/tmp/form-init1596111142512149454.clj:1:12) clojure.core=> (def *allow-unresolved-vars* true) Warning: *allow-unresolved-vars* not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic *allow-unresolved-vars* or change the name. (/tmp/form-init1596111142512149454.clj:1)
But I still haven't figured out how to use it, since unresolved variables still cause errors - these are just different errors. In addition, I do not understand the warning when it is not resolved, because the warning says that it is not declared dynamic, while it looks like it is declared dynamic in RT.java.
source share