2012-03-01 2 views
15

Vorrei disabilitare il troncamento dei valori stringa in Scala REPL.settings.maxPrintString per Scala 2.9 REPL

Il filo seguente suggerito digitando settings.maxPrintString = 0:

How to force interpreter show complete stack trace?

Purtroppo, questo non sembra funzionare 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 
    ^

C'è qualcosa che ho bisogno di importare?

ho provato :power, il che rende settings a disposizione, ma non sembra supportare 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 

vedo che scala.tools.nsc.InterpreterSettings.maxPrintString esiste, ma non sono sicuro di come ottenere un'istanza appropriata di InterpreterSettings modificare.

risposta

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 

dove l'uscita del campione presenterà troncamento senza il limite superiore.

+0

Grazie retronym! Avrei dovuto provare quello che diceva di provare! Vedo che l'impostazione 0 ora sembra davvero dire zero. C'è un modo per impostare illimitato in questi giorni, o devi solo scegliere un numero grande, come hai fatto sopra (ho provato -1, ma senza fortuna) – mrg

+1

Non importa. Int.MaxValue andrà bene, e con il bel supporto Ctrl-R, in realtà non dovrò scriverlo molto spesso. Oppure posso solo usare -i, con la soluzione -Yrepl-sync in modo che non si blocchi. – mrg

+0

Funziona anche in Scala 2.10.3 :) –