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

Peter Niederwieser pniederwieser at apple.com
Fri Jan 12 21:31:57 UTC 2018


Hi Christian,

thanks for your response!

> On Jan 12, 2018, at 9:50 AM, Christian Humer <christian.humer at gmail.com> wrote:
> Just to clarify: You want to expose Guest language objects to the user through the Evaluator, but you don't want them to use the polyglot API to access those objects so you stay independent of the runtime in use?

Yes, staying independent of the Truffle/Polyglot API is one motivation. Another is ease of use.

> We are about to introduce API to support executing `value.as <http://value.as/>(Object.class)` to return a representation that only uses core JDK classes to represent the value.
> ...
> Does this cover your use-case as well?

I think it functionally covers the use case I described. However, I’m worried that funneling a language specific conversion through an intermediate data structure (and TruffleObject protocol based conversion) will be very inefficient for large data structures. I’d much rather have *some* way to directly access/convert the language’s internal data structure. Initially I thought this could be done by implementing a “convert” message, but then I realized that message sends always return another `Value`.

While there is the option to forgo the polyglot API, I increasingly feel this is missing out on too much. For example, most languages will need something like `TruffleContext`, which is tied to the polyglot API.

-Peter


More information about the graal-dev mailing list