settings.maxPrintString for Scala 2.9 REPL

≡放荡痞女 提交于 2019-12-03 05:58:43

问题


I'd like to disable truncation of string values in the Scala REPL.

The following thread suggested typing settings.maxPrintString = 0:

How to force interpreter show complete stack trace?

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?

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

I see that scala.tools.nsc.InterpreterSettings.maxPrintString exists, but I'm not sure how to get an appropriate instance of InterpreterSettings to modify.


回答1:


  ~/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

or

$ scala -uniqid -Xprint:typer -Yshow-syms -Dscala.repl.maxprintstring=64000

where the sample output will show truncation without the higher limit.



来源:https://stackoverflow.com/questions/9516567/settings-maxprintstring-for-scala-2-9-repl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!