本文介绍了为什么在使用lein run按下ENTER键(好像是挂起)后,读行不返回,但与lein repl一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

眼前的问题是,当我使用lein run运行程序时,它进入了(read-line)部分,而我走不开了,这意味着:读取行永不返回.

以下是相关代码:

(def command (atom ""))

(defn print-prompt []
  (print "prompt> ")
  (flush)
)

(defn ask-for-input []
    (print-prompt)
    (let [x (str (read-line))]
      (println (str "User input: " x))
      (reset! command x)
    )
)

我从没在屏幕上看到用户输入:"字符串.奇怪的是,如果我运行lein repl并调用(ask-for-input),则它可以正常运行:S

解决方案

尝试蹦床跑步,它可以工作.

以下摘自leiningen常见问题解答:

The problem at hand is that when I run my program with lein run it gets to the (read-line) part and I can't get out of it, meaning: read-line never returns.

Here is the relevant code:

(def command (atom ""))

(defn print-prompt []
  (print "prompt> ")
  (flush)
)

(defn ask-for-input []
    (print-prompt)
    (let [x (str (read-line))]
      (println (str "User input: " x))
      (reset! command x)
    )
)

I never see the "User input: " string on screen.The strange part is, if I run lein repl and call (ask-for-input) then it works correctly :S

解决方案

Try lein trampoline run, it works.

The following is from leiningen FAQ:

这篇关于为什么在使用lein run按下ENTER键(好像是挂起)后,读行不返回,但与lein repl一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 00:10