在使用 python repl
时,我经常需要编辑多行代码。
所以我使用 import os
然后 os.system("notepad npad.py")
在 clojure 中,我首先运行 (use '[clojure.java.shell :only [sh]])
然后我运行 (sh "notepad""jpad.clj")
这会启动记事本,但不是以有用的方式,因为 clojure repl
现在挂起。换句话说,在我关闭记事本之前,我无法在 repl
中输入代码,我希望两者都保持打开状态。
我知道不用 clojure 也可以轻松打开记事本,所以这没什么大不了的。但是,有没有办法让clojure在不挂起的情况下启动一个外部进程呢?
最佳答案
future
是一种让工作在后台运行的便捷方式,以后很容易检查进程。
user> (def notepad-process (future (sh "emacs" "jpad.clj")))
#'user/notepad-process
编辑文件一段时间,如果需要退出代码,稍后检查进程:
user> @notepad-process
{:exit 0, :out "", :err ""}
关于python - 为什么我的 clojure shell 结果与 python 中的结果不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15010364/