从REPL(Cloure 1.4.0)我试图使用source
宏来显示我的功能把定义 - 但它与“未找到源”为什么'源'不工作?
回复我可以source
使用source
本身喜欢这个(并可以看到它使用source-fn
) - 但不知道为什么它不喜欢我的defn x[] "hello"
函数定义?
user=> (source source)
(defmacro source
"Prints the source code for the given symbol, if it can find it.
This requires that the symbol resolve to a Var defined in a
namespace for which the .clj is in the classpath.
Example: (source filter)"
[n]
`(println (or (source-fn '~n) (str "Source not found"))))
nil
user=> (defn x[] "hello")
#'user/x
user=> (source x)
Source not found
nil
user=>
那么有没有找到in-REPL定义函数(等)的'源'的方法?例如,如果我只是在REPL上编写代码,但想保存我的工作(就目前的情况而言) - 那可能吗? – monojohnny