Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

settings.maxPrintString for Scala 2.9 REPL

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.

like image 288
mrg Avatar asked Mar 01 '12 12:03

mrg


1 Answers

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

like image 147
retronym Avatar answered Oct 22 '22 15:10

retronym