Open niconomaa opened 5 years ago
Initial idea was to call language specific String representation methods (such as obj.__repr__()
for e.g. python) on foreign objects that ijavascript could not evaluate with default obj.inspect
as implemented on feature branch #13. Will revert back to " " + obj
as this seems to be cleaner approach.
In this comment, we try to consolidate observations of different behaviors of output / error handling across languages.
We also compare the output / error handling inside Jupyter Notebook to the behavior when using the Polyglot.eval
interface inside a console node --polyglot --jvm
session to potentially spot errors which are not caused by our implementation but instead by GraalVM.
Output of print()
is not shown, NEL internal error because the execution of the last line doesn't yield anything which can be automatically converted and shown as cell output (yields null
instead).
Behaves as expected.
> result = Polyglot.eval('python', 'a = 0\nprint(a)\na += 1');
0
null
Behaves as expected.
Behaves as expected.
> result = Polyglot.eval('python', '<----');
Error: SyntaxError: invalid syntax
at Object.eval (native)
Output of puts
is not shown
Behaves as expected.
> result = Polyglot.eval('ruby', 'a = 0\nputs a\na += 1');
0
1
No error message in Notebook, NEL internal error on Node console, kernel is stuck in execution and is unresponsive.
Unrelated JS error is shown.
> result = Polyglot.eval('ruby', '<----');
TypeError: Object prototype may only be an Object or null: DynamicObject@5d75f90e<Method>
at Function.setPrototypeOf (native)
at deprecate (internal/util.js:70:10)
at formatValue (internal/util/inspect.js:481:21)
at Object.inspect (internal/util/inspect.js:191:10)
at Domain.debugDomainError (repl.js:439:34)
at Domain.emit (events.js:189:13)
at Domain.emit (domain.js:441:20)
at REPLServer.defaultEval (repl.js:353:26)
at bound (domain.js:395:14)
at REPLServer.runBound (domain.js:408:12)
Output of print()
is not shown
Behaves as expected.
> result = Polyglot.eval('R', 'a = 0\nprint(a)\nb = "asdf"');
[1] 0
'asdf'
Behaves as expected.
Behaves as expected.
> result = Polyglot.eval('R', '<----');
Error: parse exception
at Object.eval (native)
Behaves as expected.
Behaves as expected.
> result = Polyglot.eval('js', 'a = 0\nconsole.log(a)\na += 1');
0
1
Behaves as expected.
Behaves as expected.
> result = Polyglot.eval('js', '<----');
Error: SyntaxError: <eval>:1:0 Expected an operand but found <
<----
^
at Object.eval (native)
Errors are returned inconsistently depending on the language used in the kernel cell. Consistent and useful error messages are desired.