jshell tool: what should the interactive output look like?

Robert Field robert.field at oracle.com
Mon Jan 25 03:36:25 UTC 2016

Below I list interesting snippet and command input, with the current 
default ('d:') and concise ('c:') feedback, Brian's proposal ('b:) and 
some other (numbered) alternatives


-> Math.sqrt(Math.PI)

d: |  Expression value is: 1.7724538509055159
    |    assigned to temporary variable $3 of type double

c: |  $3 : 1.7724538509055159

b:  => 1.7724538509055159
    (assigned to temporary $3 of type double)

0: |  double $3 : 1.7724538509055159
    |  Added temporary variable $3

1: |  double $3 : 1.7724538509055159

-> Arrays.asList("Hello", "World!", "How", "Are", "You").stream()  // 
another example

d: |  Expression value is: java.util.stream.ReferencePipeline$Head at 5f5a92bb
    |    assigned to temporary variable $11of type Stream<String>

c: |  $11 : java.util.stream.ReferencePipeline$Head at 51016012

b:  => java.util.stream.ReferencePipeline$Head at 51016012
    (assigned to temporary $11 of type Stream<String>)

0: |Stream<String>$11 : java.util.stream.ReferencePipeline$Head at 51016012
    |  Added temporary variable $11

1: |Stream<String>$11 : java.util.stream.ReferencePipeline$Head at 51016012

VAR CREATE (initial value)

-> double x = Math.sqrt(Math.PI)

d: |  Added variable x of type double with initial value 1.7724538509055159

c: |  x : 1.7724538509055159

b: (declared variable x of type double)

0: | doublex : 1.7724538509055159
    |  Added variable x

1: | doublex : 1.7724538509055159

4:  => 1.7724538509055159
(declared variable x of type double)

VAR CREATE (no initial value)

-> double x

d: |  Added variable x of type double

c: |  (NO OUTPUT)

b: (declared variable x of type double)

0:|  Added variable x

1: | doublex : 0.0


-> k = Math.getExponent(Math.random())

d: |  Variable k has been assigned the value -2

c: |  k : -2


1: |  int k : -2

4:  => -2


-> x

d: |  Variable x of type double has value 1.7724538509055159

c: |  x : 1.7724538509055159

b: => 1.7724538509055159

1: | doublex : 1.7724538509055159

METHOD DECL (class, interface, enum, too similarto show)

-> void m() { }

d: |  Added method m()


b: (defined method m())


-> /drop m



b: (dropped method m())

1: |  Dropped method m()


Currently display in default but not concise.

| Editor set to: %s
| Path %s added to classpath
| Feedback mode: %s
|  Prompt will (not) display.


My vote for new default is '1' (where it is shown, and current default 
otherwise).  This is mostly like concise feedback but adding the type 
which is often important information. A variation would be to use '=' 
instead of colon, but since then it would be valid code (and in simple 
cases will be the same as the input) I think that would be confusing.

I think it is important to set the feedback off from the user's output. 
Brian proposes parenthesis, which make it clear they are parenthetical 
and presumably not shown in concise feedback, but parenthesis are likely 
to occur in the user output and is very likely to occur in the feedback. 
The pipe symbol is currently used (to quote-off) the feedback -- I think 
it works well -- is visually clean.

I like the clean division of what goes away in a concise mode. Option 
(0) shows one choice for this (which also is more symmetric with 
methods, classes,...).  Expressions are probably the most important 
snippets to have crisp output, and unfortunately, this adds pure noise 
in this case as soon as the user understands that expressions create 
temporaries which are named with a dollar sign.

"Added" vs "defined": I like "defined" better, but "Added" is used to 
differentiate it from "Modified" and "Replaced".   We could use 
"Defined", "Modified definition", and "Replaced definition".

I'd like to hear everyone's opinion.  Including what options I did not list.


More information about the kulla-dev mailing list