sigrlami
sigrlami

Reputation: 1832

Clojure Repl Unable to resolve symbol for all functions

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

Upvotes: 3

Views: 3093

Answers (1)

Joost Diepenmaat
Joost Diepenmaat

Reputation: 17761

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

Upvotes: 6

Related Questions