JShell: showing and retaining settings

Som Snytt som.snytt at gmail.com
Wed Oct 12 04:44:43 UTC 2016


FWIW, Scala REPL works that way.

scala> :se
-d = .
-deprecation = true
-encoding = UTF-8
-feature = true
-nowarn = false

scala> :se -Ywarn-unused

scala> :se
-Ywarn-unused = true
-d = .
-deprecation = true
-encoding = UTF-8
-feature = true
-nowarn = false

scala> { val x, y = 42 ; x + 17 }
<console>:12: warning: local val in value res0 is never used
       { val x, y = 42 ; x + 17 }
                ^
res0: Int = 59

scala> :replay -nowarn
Replaying: { val x, y = 42 ; x + 17 }
res0: Int = 59

The settings, reset and replay commands just take compiler settings to use.
I can remember that.

There are legacy settings on the $intp interpreter, which I can't
rediscover without autocompletion.

scala> $intp.isettings.
allSettings   deprecation_=            maxPrintString   unwrapStrings
deprecation   maxAutoprintCompletion   toString

scala> $intp.isettings.maxPrintString = 20
$intp.isettings.m...

I stopped using switches with commands, as a complication. Help and usage
becomes cumbersome. In this case, what's wrong with "/retain" also showing
settings, for symmetry? "/set -retain" is more to type. Also, "/set" and
"/ret" pair nicely.



On Tue, Oct 11, 2016 at 1:09 PM, Robert Field <robert.field at oracle.com>
wrote:

> In response to a review request for
>
>     8163840: jshell tool: provide way to display configuration settings
>
> I had an in-depth discussion with Brian about the settings related
> commands -- resulting in a proposed syntax significantly different than
> current or the webrev.  I'd like to vet this at the design level before
> implementing it (again).  Your feedback is requested.
>
> /set as before.
>
> Showing settings with '/set' without specifying a setting (rather than
> '/set -show' in the RFR)..  This is consistent with many other shells,
> including bash.  It also reduces the commands to learn.
>
> Since /set would also show settings retained between sessions, for
> symmetry, /retain would be rolled into /set as /set -retain ...
>
> Since mode settings are very extensive they would be shown only for
> requested modes.
>
> Examples ---
>
> jshell> /set
> |  /set editor -retain kwrite
> |  /set editor -default
> |  /set start -none
> |  /set feedback normal
> |
> | For mode settings use:  /show mode <mode>
> | Current set modes: verbose normal concise silent
>
> jshell> /set editor
> |  /set editor -retain kwrite
> |  /set editor -default
>
> jshell> /set mode concise
> |  /set mode concise -quiet
> |  /set prompt concise "jshell> " "   ...> "
> |  /set format concise typeKind "class" class
> |  /set format concise typeKind "interface" interface
> |  /set format concise typeKind "enum" enum
> |  /set format concise typeKind "annotation interface" annotation
> |  /set format concise pre "|  "
> |  /set format concise resolve "{until}{unrerr}"
> modified,added,used,replaced
> |  /set format concise err "%6$s"
> |  /set format concise unrerr "{unresolved} is declared" unresolved1-error0
> |  /set format concise unrerr "{unresolved} are declared"
> unresolved2-error0
> |  /set format concise unrerr " this error is corrected: {errors}"
> unresolved0-error1
> |  /set format concise unrerr "{unresolved} is declared and this error is
> corrected: {errors}" unresolved1-error1
> |  /set format concise unrerr "{unresolved} are declared and this error is
> corrected: {errors}" unresolved2-error1
> |  /set format concise unrerr " these errors are corrected: {errors}"
> unresolved0-error2
> |  /set format concise unrerr "{unresolved} is declared and these errors
> are corrected: {errors}" unresolved1-error2
> |  /set format concise unrerr "{unresolved} are declared and these errors
> are corrected: {errors}" unresolved2-error2
> |  /set format concise display "{result}{pre}created scratch variable
> {name} : {type}{post}" expression-modified,added,replaced-primary
> |  /set format concise display "{result}{pre}value of {name} :
> {type}{post}" varvalue-primary
> |  /set format concise display "{result}{pre}assigned to {name} :
> {type}{post}" assignment-primary
> |  /set format concise display "{result}{pre}{action} variable {name} :
> {type}{resolve}{post}" varinit,vardecl
> |  /set format concise display "{pre}{action} variable
> {name}{resolve}{post}" varinit,vardecl-notdefined
> |  /set format concise display "{pre}{action} variable {name}{post}"
> varinit,expression,vardecl-dropped
> |  /set format concise display "{pre}{action} variable {name}, reset to
> null{post}" varinit,vardecl-replaced-update-ok
> |  /set format concise display "{pre}{action} {typeKind}
> {name}{resolve}{post}" class,enum,annotation,interface
> |  /set format concise display "{pre}{action} method
> {name}({type}){resolve}{post}" method
> |  /set format concise display "{pre}attempted to use {typeKind}
> {name}{resolve}{post}" class,enum,annotation,interface-used
> |  /set format concise display "{pre}attempted to call method
> {name}({type}){resolve}{post}" method-used
> |  /set format concise display "" modified,added,dropped,overwro
> te,replaced-update
> |  /set format concise display "{pre}{action} variable {name}, reset to
> null{post}" varinit,vardecl-replaced-update-ok
> |  /set format concise display "{result}" varinit,expression,assignment,
> varvalue,vardecl-modified,added,replaced-primary-ok
> |  /set format concise display "" class,enum,varinit,annotation,
> assignment,method,vardecl,interface-ok
> |  /set format concise type "%2$s"
> |  /set format concise errorpre "|  "
> |  /set format concise result "{name} ==> {value}{post}"
> modified,added,replaced-primary-ok
> |  /set format concise unresolved "%4$s"
> |  /set format concise errorline "{post}{pre}    {err}"
> |  /set format concise post "%n"
> |  /set format concise name "%1$s"
> |  /set format concise action "created" added-primary
> |  /set format concise action "modified" modified-primary
> |  /set format concise action "replaced" replaced-primary
> |  /set format concise action "overwrote" overwrote-primary
> |  /set format concise action "dropped" dropped-primary
> |  /set format concise action "  update created" added-update
> |  /set format concise action "  update modified" modified-update
> |  /set format concise action "  update replaced" replaced-update
> |  /set format concise action "  update overwrote" overwrote-update
> |  /set format concise action "  update dropped" dropped-update
> |  /set format concise errorpost "%n"
> |  /set format concise until ", however, it cannot be instanciated or its
> methods invoked until" class-primary-defined
> |  /set format concise until ", however, its methods cannot be invoked
> until" interface-primary-defined
> |  /set format concise until ", however, it cannot be used until"
> enum,annotation-primary-defined
> |  /set format concise until ", however, it cannot be invoked until"
> method-primary-defined
> |  /set format concise until ", however, it cannot be referenced until"
> primary-notdefined
> |  /set format concise until " which cannot be instanciated or its methods
> invoked until" class-update-defined
> |  /set format concise until " whose methods cannot be invoked until"
> interface-update-defined
> |  /set format concise until " which cannot be invoked until"
> method-update-defined
> |  /set format concise until " which cannot be referenced until"
> update-notdefined
> |  /set format concise value "%3$s"
> |  /set format concise errors "%5$s"
> |  /set truncation concise 80
> |  /set truncation concise 1000 expression,varvalue
>
> jshell> /set start -retain -default
>
>
> Thoughts?
>
>
>


More information about the kulla-dev mailing list