我正在学习Clojure,到目前为止,我还不能理解这个小难题,我确信它是非常基本的。
我有这个文件:
(ns cloapp.core
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!")
(println "Well Hi there, im a string !")
(println "Why wont this work !")
(myFunc "Hiya"))
(defn myFunc [aVar]
(println aVar))如果我试着用来运行它,
lein run它抱怨说,
Caused by: java.lang.RuntimeException: Unable to resolve symbol: myFunc in this context但是如果我从main中删除对myFunc的调用,
lein repl
cloapp.core=> (myFunc "Hiya !")
Hiya !
nil
cloapp.core=> 那我就可以给它打电话了。为什么会这样呢?我假设这与名称空间有关,但仔细阅读后,我无法理解它。
一个
发布于 2012-12-14 06:32:52
myFunc符号尚未定义,因此main找不到它。如果你把myFunc的定义移到main上面,那么它就会起作用。
https://stackoverflow.com/questions/13869581
复制相似问题