2

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)

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.