2012-03-01 16 views
15

Me gustaría deshabilitar el truncamiento de valores de cadena en Scala REPL.settings.maxPrintString para Scala 2.9 REPL

El siguiente hilo sugirió escribir settings.maxPrintString = 0:

How to force interpreter show complete stack trace?

Desafortunadamente, esto no parece trabajar con 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 
    ^

¿Hay algo que necesito para importar?

me trataron :power, lo que hace settings disponible, pero no parece apoyar 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 

veo que scala.tools.nsc.InterpreterSettings.maxPrintString existe, pero no estoy seguro de cómo obtener una instancia apropiada de InterpreterSettings Modificar.

Respuesta

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 

o

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

donde la salida de la muestra se mostrará truncamiento sin el límite superior.

+0

Gracias retronym! ¡Debería haber intentado lo que decía probar! Veo que establecer 0 ahora parece significar cero. ¿Hay alguna manera de establecer el límite en estos días, o simplemente tienes que elegir un número grande, como lo has hecho anteriormente (intenté -1, pero no tuve suerte) – mrg

+1

No importa. Int.MaxValue estará bien, y con el buen soporte de Ctrl-R, no tendré que escribirlo muy a menudo. O puedo usar -i, con la solución de sincronización-Repl para que no cuelgue. – mrg

+0

También funciona en Scala 2.10.3 :) –

Cuestiones relacionadas