Scala 2.9 REPL 的 settings.maxPrintString [英] settings.maxPrintString for Scala 2.9 REPL
问题描述
我想在 Scala REPL 中禁用字符串值的截断.
I'd like to disable truncation of string values in the Scala REPL.
以下线程建议输入settings.maxPrintString = 0
:
不幸的是,这似乎不适用于 Scala 2.9:
Unfortunately, this doesn't seem to work with Scala 2.9:
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.
scala> settings.maxPrintString = 0
<console>:10: error: not found: value settings
val $ires0 = settings.maxPrintString
^
<console>:7: error: not found: value settings
settings.maxPrintString = 0
^
有什么我需要导入的吗?
Is there something I need to import?
我尝试了 :power
,它使 settings
可用,但它似乎不支持 maxPrintString
:
I tried :power
, which makes settings
available, but it doesn't seem to support maxPrintString
:
scala> :power
** Power User mode enabled - BEEP BOOP SPIZ **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._ and definitions._ also imported **
** Try :help, vals.<tab>, power.<tab> **
scala> settings
res0: scala.tools.nsc.Settings =
Settings {
-d = .
-Yrich-exceptions = true
-classpath = bin:lib/*
-encoding = UTF-8
}
scala> settings.maxPrintString = 0
<console>:31: error: value maxPrintString is not a member of scala.tools.nsc.Settings
val $ires9 = settings.maxPrintString
^
<console>:28: error: value maxPrintString is not a member of scala.tools.nsc.Settings
settings.maxPrintString = 0
我看到 scala.tools.nsc.InterpreterSettings.maxPrintString
存在,但我不确定如何获得 InterpreterSettings
的适当实例进行修改.>
I see that scala.tools.nsc.InterpreterSettings.maxPrintString
exists, but I'm not sure how to get an appropriate instance of InterpreterSettings
to modify.
推荐答案
~/code/scala scala29
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :power
** Power User mode enabled - BEEP BOOP SPIZ **
** :phase has been set to 'typer'. **
** scala.tools.nsc._ has been imported **
** global._ and definitions._ also imported **
** Try :help, vals.<tab>, power.<tab> **
scala> vals.isettings.maxPrintString
maxPrintString maxPrintString_=
scala> vals.isettings.maxPrintString = 10000
vals.isettings.maxPrintString: Int = 10000
或
$ scala -uniqid -Xprint:typer -Yshow-syms -Dscala.repl.maxprintstring=64000
示例输出将在没有上限的情况下显示截断.
where the sample output will show truncation without the higher limit.
这篇关于Scala 2.9 REPL 的 settings.maxPrintString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!