Clojure REPL Unable to resolve symbol

10,089

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.

If you want to switch namespaces

(ns clojure-noob.core) ;; switch to the correct namespace
(can-vote) ;; call the function

If you want to call it with the fully qualified symbol from the user namespace

(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.

Share:
10,089
Mahmud Adam
Author by

Mahmud Adam

Updated on June 04, 2022

Comments

  • Mahmud Adam
    Mahmud Adam almost 2 years

    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")))