Clojure Repl无法解析所有函数的符号 [英] Clojure Repl Unable to resolve symbol for all functions

查看:122
本文介绍了Clojure Repl无法解析所有函数的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用Leiningen创建的项目和以下代码在 Core.clj 文件中:

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

和其他功能

em> clojure-jack-in 并使用(ns hyperstring.core)切换到我的命名空间。接下来,我试图启动文件中的任何函数并获取REPL asnswer:

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

/ strong>也许有些选项或deps?

What do I miss? Maybe some option or deps ?

clojure-1.4.0,Leiningen-2.0,swank-1.4.4

clojure-1.4.0, Leiningen-2.0, swank-1.4.4

推荐答案

(ns some.thing)不只是切换到命名空间;它会创建它。

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

您应该首先使用(例如)加载您的函数:

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

Cc c> (require'hyperstring.core)

(require 'hyperstring.core)

(slime-compile-and-load-file), Cc Cp (slime-repl-set-package)。

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

这篇关于Clojure Repl无法解析所有函数的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆