gpt4 book ai didi

clojure - 为什么 `(exit)` 在 REPL 中并不总是可用?

转载 作者:行者123 更新时间:2023-12-02 11:00:29 26 4
gpt4 key购买 nike

今天我发现了一些奇怪的事情。当我不在项目“中”时(即 shell 不在 clojure 项目目录中),我可以使用 exit 退出 REPL:

shell$ lein repl
REPL started; server listening on localhost port 43712
user=> (+ 3 4)
7
user=> (exit)
shell$ echo '<span>not in <s>kansas</s>clojure anymore</span>'

当我“在”一个项目中(即 shell 位于 clojure 项目的目录中)时,我无法使用exit:

shell$ cd my_clojure_project
shell$ lein repl
REPL started; server listening on localhost port 69237
user=> (* 8 4)
32
user=> (exit)
java.lang.Exception: Unable to resolve symbol: exit in this context (NO_SOURCE_FILE:2)
user=>

这里有什么问题?

<小时/>

Clojure 版本(对于两个示例):

user=> (clojure-version)
"1.2.1"

Leiningen 版本(对于两个示例):

shell$ lein -v
Leiningen 1.6.1 on Java 1.6.0_26 Java HotSpot(TM) 64-Bit Server VM

最佳答案

这似乎是因为存在项目时 leiningen.core 命名空间不可用。更具体地说,当有一个项目时,你的项目的代码是 evaluated in a separate ClassLoader类路径上只有您的项目。因此,Leiningen 的所有功能均不可用。

Leiningen 2 REPL 没有这个问题。

关于clojure - 为什么 `(exit)` 在 REPL 中并不总是可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10232760/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com