jshell tool: what should the interactive output look like?

Dan Smith daniel.smith at oracle.com
Mon Jan 25 17:20:20 UTC 2016

I like 1, among those listed here.

I'm sympathetic to Brian's concern that the metadata not drown out the main focus: the resulting value.  Reordering the output might work?  I'll try something below.

I also think that the subtle difference between adding, updating, etc. a declaration does not require making a big deal about it.  For users who care about this, they can learn to look for subtle cues, and maybe a variation in the symbols used would suffice.  See below for this, too.

One thing to worry about: what happens when types or 'toString' output become unwieldy?  That potentially kills the nice compact representation.  Is any attempt made to abbreviate, get rid of newlines, etc?  (I run into this problem quite a bit when debugging javac, because 'toString' on AST nodes often produces multi-line output.)

> On Jan 24, 2016, at 8:36 PM, Robert Field <robert.field at oracle.com> wrote:
> 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)

| 1.7724538509055159 => double $3

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

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

> VAR CREATE (initial value)

| 1.7724538509055159 => double x

> VAR CREATE (no initial value)
> -> double x

| 0.0 => double x

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

| -2 ~> int k

(Assignment is weird, because it's officially an expression that happens to have a side-effect, but everybody treats it as a statement.  I guess 'k +=' and '++k' would also be reported as an update, while 'k++' and nested assignments would be treated like complex expressions?)

> -> x
> d: |  Variable x of type double has value 1.7724538509055159
> c: |  x : 1.7724538509055159
> b: => 1.7724538509055159
> 1: | doublex : 1.7724538509055159

| 1.7724538509055159 <= double x

(A little weird that I can query vars but not methods and classes. If there were a unified way to query all of them, there might be an accompanying unified output that looks more like a declaration.)

> METHOD DECL (class, interface, enum, too similarto show)
> -> void m() { }

| => void m()

(Or, for redeclaration, '~> void m()')

> -> /drop m

| Dropped method m()

(This is fine -- when the input is a command, I think it's reasonable to have separate conventions from when the input is Java code.)


More information about the kulla-dev mailing list