Clojure新手 - 命名空间的麻烦

AlM*_*ean 4 clojure

我正在学习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))
Run Code Online (Sandbox Code Playgroud)

如果我尝试运行它,

lein run
Run Code Online (Sandbox Code Playgroud)

它抱怨并说,

Caused by: java.lang.RuntimeException: Unable to resolve symbol: myFunc in this context
Run Code Online (Sandbox Code Playgroud)

但是,如果我从main中删除对myFunc的调用并执行,

lein repl
cloapp.core=> (myFunc "Hiya !")
Hiya !
nil
cloapp.core=> 
Run Code Online (Sandbox Code Playgroud)

然后我可以打电话给它.为什么是这样 ?我假设它与命名空间有关,但是阅读它我无法解决它.

一个

Kev*_*vin 7

myFunc符号尚未定义,因此main无法找到它.如果将myFunc的定义移到main之上,那么它将起作用.