我想在Scala REPL中禁用截断字符串值。
以下主题建议输入settings.maxPrintString = 0
:
How to force interpreter show complete stack trace?
不幸的是,这似乎不适用于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
^
我需要导入什么东西吗?
我尝试了:power
,这使settings
可用,但它似乎不支持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
的适当实例进行修改。
答案 0 :(得分:24)
~/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
其中示例输出将显示截断而没有上限。