对于那些不知道 *print-length*
代表什么的人:
如果您(set! *print-length* 200)
,并在 REPL 中计算 (range)
,这通常会导致获得无限的数字列表打印,仅打印前 200 个数字。
我正在尝试将其设置为 profiles.clj
中所有 REPL 的默认值。
现在我明白了,但它不起作用:
{:user {:plugins [[lein-swank "1.4.4"]
[lein-catnip "0.5.0"]]
:repl-options {*print-length* 200}}
:dev {:dependencies [[clj-ns-browser "1.2.0"]
[org.clojure/tools.trace "0.7.5"]]}}
这有什么问题吗?
更新。 Tnx Michal 回答了这个问题。我的固定 profiles.clj
现在看起来像这样。请注意,它仅适用于项目内部。
{:user {:plugins [[lein-swank "1.4.4"]
[lein-catnip "0.5.0"]]
:repl-options {:init (set! *print-length* 200)}}
:dev {:dependencies [[clj-ns-browser "1.2.0"]
[org.clojure/tools.trace "0.7.5"]]}}
最佳答案
:repl-options
需要是 Leiningen 的 repl
任务支持的选项映射;其他任何内容都将被忽略。 *print-length*
不是一个有效的选项(nil
也不是);我必须检查以确保此处的键是否被评估,但这不会'无论哪种方式都不起作用)。
相反,你应该使用类似的东西
:repl-options {:init (set! *print-length* 200)}
请参阅 Leiningen 存储库根目录中的 sample.project.clj
,了解可用选项的说明(包括 :init
)。
关于clojure - 在 profile.clj 中为 *print-length* 提供默认值的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14664486/