Clojure Repl Unable to resolve symbol for all functions

不想你离开。 提交于 2019-12-12 14:50:08

问题


I have project created with Leiningen and following code in Core.clj file:

(ns hyperstring.core
(:use [clojure.pprint :only (pprint)])
(:require [clojure.java.io :as io]
          [clojure.string :as str])
(:import  [java.io File]))

;;read file line by line
(defn read-line-by-line [filepath]
 (with-open [rdr (reader filepath)]
   (doseq [line (line-seq rdr)]
     (println line))))

;;write to a new file
(defn write-file [filepath]
(with-open [wrtr (writer filepath)]
    (.write wrtr "Line to be written")))

and other functions

I enter REPL with clojure-jack-in and switch with (ns hyperstring.core) to my namespace. Next, I'm trying to start any function in file and get REPL asnswer:

java.lang.Exception: Unable to resolve symbol: read-line-by-line in this context

What do I miss? Maybe some option or deps ?

clojure-1.4.0, Leiningen-2.0, swank-1.4.4


回答1:


(ns some.thing) does not just switch to a namespace; it creates it.

You should load your functions first using (for example):

(require 'hyperstring.core)

or from Slime, C-c C-k (slime-compile-and-load-file), C-c C-p (slime-repl-set-package) while in core.clj.



来源:https://stackoverflow.com/questions/11508881/clojure-repl-unable-to-resolve-symbol-for-all-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!