Closed padreati closed 4 weeks ago
During an execution of a cell code, the instructions are split into code snippets and send to JShell instance (if the snippets are not magics, but Java code).
The last command is aimed to behave like the python kernel, aka to display the value of the last command. The last command can be a method which returns void
, which will display nothing. The last command could be a call to a method which returns something. The effect would be that the returned object will be displayed. Also, the command could be simply the name of a variable. In that case the value of the variable will be displayed.
The previous behavior aims to mimic the python kernels.
How it is decided if the result of the last instruction is displayed? The answer is that we allow display values only for specific subkind of snippets defined here: https://download.java.net/java/early_access/jdk23/docs/api/jdk.jshell/jdk/jshell/Snippet.SubKind.html
The problem is that when something like the following is executed: int[] x = new int[1]; x[0] = 3;
the same subkind of snippet is considered by JShell TEMP_VAR_EXPRESSION_SUBKIND
as it is for 10
, for example. This creates a problem since while it is desirable to display the result for the last example, it is not desirable to do that for the first example.
I really don't know how this can be implemented properly. I will close it for now, but if anybody have any idea I am glad to reopen it.
After an assignment instruction the value is displayed. This should not happen.