GithubHelp home page GithubHelp logo

Comments (2)

jonashering avatar jonashering commented on June 3, 2024

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.

from ipolyglot.

jakob-ed avatar jakob-ed commented on June 3, 2024

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.

Python - stdout - Jupyter Notebook

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).

image

Python - stdout - Console

Behaves as expected.

> result = Polyglot.eval('python', 'a = 0\nprint(a)\na += 1');
0
null

Python - stderr - Jupyter Notebook

Behaves as expected.

image

Python - stderr - Console

Behaves as expected.

> result = Polyglot.eval('python', '<----');
Error: SyntaxError: invalid syntax
    at Object.eval (native)

Ruby - stdout - Jupyter Notebook

Output of puts is not shown

image

Ruby - stdout - Console

Behaves as expected.

> result = Polyglot.eval('ruby', 'a = 0\nputs a\na += 1');
0
1

Ruby - stderr - Jupyter Notebook

No error message in Notebook, NEL internal error on Node console, kernel is stuck in execution and is unresponsive.

image

Ruby - stderr - Console

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)

R - stdout - Jupyter Notebook

Output of print() is not shown

image

R - stdout - Console

Behaves as expected.

> result = Polyglot.eval('R', 'a = 0\nprint(a)\nb = "asdf"');
[1] 0
'asdf'

R - stderr - Jupyter Notebook

Behaves as expected.

image

R - stderr - Console

Behaves as expected.

> result = Polyglot.eval('R', '<----');
Error: parse exception
    at Object.eval (native)

JS - stdout - Jupyter Notebook

Behaves as expected.

image

JS - stdout - Console

Behaves as expected.

> result = Polyglot.eval('js', 'a = 0\nconsole.log(a)\na += 1');
0
1

JS - stderr - Jupyter Notebook

Behaves as expected.

image

JS - stderr - Console

Behaves as expected.

> result = Polyglot.eval('js', '<----');
Error: SyntaxError: <eval>:1:0 Expected an operand but found <
<----
^

    at Object.eval (native)

from ipolyglot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.