为什么下面的代码编译不通过?
(defn testit [asym] (var asym))
错误是:
CompilerException java.lang.RuntimeException: Unable to resolve var: asym in this context, compiling:(NO_SOURCE_PATH:1)
为什么下面的代码编译不通过?
(defn testit [asym] (var asym))
错误是:
CompilerException java.lang.RuntimeException: Unable to resolve var: asym in this context, compiling:(NO_SOURCE_PATH:1)
asym没有 a var,它是本地的;在这种情况下,您定义为testitvar 值的函数的唯一参数。
如果你想asym从那个函数返回:
(defn testit [asym] asym)
如果asym是一个符号,它命名一个你想返回的 var,然后使用resolve:
(defn testit [asym] (resolve asym))
总注:是对应读者语法(var x)的扩展特殊形式#'x。