我还不知道答案,但似乎从 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."