Clojure REPL 无法解析符号 [英] Clojure REPL Unable to resolve symbol
问题描述
从 lein run 执行此函数时,程序按预期执行.但是我正在尝试 atom.io 的 proto-repl 包,当我使用 proto-repl 调用该函数时,它给出了CompilerException java.lang.RuntimeException: Unable to resolve symbol: can-vote in this context".这是我的功能:
When executing this function from lein run, the program executes as expected. But I am trying out atom.io's proto-repl package and when I call the function using the proto-repl, it gives a "CompilerException java.lang.RuntimeException: Unable to resolve symbol: can-vote in this context." Here is my function:
(defn can-vote
[]
(println "Enter age: ")
(let [age (read-line)]
(let [new-age (read-string age)]
(if (< new-age 18) (println "Not old enough")))
(println "Yay! You can vote")))
推荐答案
当您的 repl 开始时,它可能会将您置于 user
命名空间中.您需要移动到 clojure-noob.core
命名空间或使用完全限定符号调用它.
When your repl starts, it likely puts you in the user
namespace. You either need to move to your clojure-noob.core
namespace or call it with the fully qualified symbol.
如果你想切换命名空间
(ns clojure-noob.core) ;; switch to the correct namespace
(can-vote) ;; call the function
如果您想使用来自用户命名空间的完全限定符号来调用它
(require 'clojure-noob.core) ;; first require the namespace
(clojure-noob.core/can-vote) ;; call the fully qualified function
您可以阅读更多关于命名空间和从其他命名空间和库调用函数的信息 此处.
You can read much more about namespaces and calling functions from other namespaces and libraries here.
这篇关于Clojure REPL 无法解析符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!