我还没有找到答案,但从 Clojure 版本 1.10.0-RC2 开始,似乎出现了行为上的差异。
$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-RC1"}}}'
Clojure 1.10.0-RC1
user=> #=(println 1)
1
nil
user=> ^D
$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-RC2"}}}'
Clojure 1.10.0-RC2
user=> #=(println 1)
1
1
nil
进一步的调查表明,新行为首次出现在以下提交中:https://github.com/clojure/clojure/commit/817abb3d0ca3b7ee80cfe17b5cfe3ea8306f0720
猜测:该提交包括了一个新的用作 Clojure 默认 REPL 的 renumbering-read
函数,如果在第一次读取成功后,它将再次读取。
(defn renumbering-read
"Reads from reader, which must be a LineNumberingPushbackReader, while capturing
the read string. If the read is successful, reset the line number and re-read.
The line number on re-read is the passed line-number unless :line or
:clojure.core/eval-file meta are explicitly set on the read value."