Question about the new polyglot API and its `Value` class

Peter Niederwieser pniederwieser at apple.com
Thu Jan 11 22:52:57 UTC 2018


Hello,

I have a broader question related to the new polyglot API and its `Value` class:

Say we have a Truffle language that comes with an `Evaluator` Java API for evaluating language scripts from Java code. The result of evaluating a language script is an object (set of named properties). Say the `Evaluator` API has its own external object representation (which it returns to the caller) that is fully decoupled from the language's internal object representation and the Truffle/Polyglot API.

Even though it doesn’t have a need for language interop, the `Evaluator` implementation may want to use the `org.graalvm.polyglot` API, as this is the only way to leverage Truffle features such as language contexts and node instrumentation. In this case, script evaluation will produce an `org.graalvm.polyglot.Value`. Given that the internal language object underlying the `Value` cannot be accessed, and that every message send returns another `Value`, is there any way for the `Evaluator` implementation to easily/efficiently perform the conversion from internal to external object representation? (Evaluating a script may produce an object that is the root of a large object graph.)

Thanks,
Peter


More information about the graal-dev mailing list