Reputation: 8295
Why the following code cann't pass compilation?
(defn testit [asym] (var asym))
The error is:
CompilerException java.lang.RuntimeException: Unable to resolve var: asym in this context, compiling:(NO_SOURCE_PATH:1)
Upvotes: 2
Views: 76
Reputation: 5916
asym
there is not a var
, it's a local; in this case, the sole argument to the function that you're defining as the value of the testit
var.
If you want to return asym
from that function:
(defn testit [asym] asym)
If asym
is a symbol that names a var you want to return, then use resolve
:
(defn testit [asym] (resolve asym))
General note: (var x)
is the expanded special form corresponding to the reader syntax #'x
.
Upvotes: 2