從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