Skip to content

Add polyglot object access, callable closures, and immutable snapshots - #9

Open
Sam Gammon (sgammon) wants to merge 1 commit into
feature/independent-engine-runtimefrom
feature/polyglot-object-interop
Open

Sam Gammon (sgammon) wants to merge 1 commit into
feature/independent-engine-runtimefrom
feature/polyglot-object-interop

Conversation

@sgammon

Copy link
Copy Markdown
Member

Enable Context.eval("pkl", source) to return lazy, read-only Pkl objects through the Truffle interop protocol. JavaScript and Java can read properties and collections, preserve object identity, and invoke function-valued properties with Pkl's normal argument and return checks.

Add explicit Pkl.snapshot(...) / PolyglotContext.snapshot(...) conversion for foreign data passed into Pkl. Copies preserve aliases and remain usable after the source context closes; cycles, callbacks, lossy numbers, known side-effecting accessors, and oversized graphs are rejected. Standalone evaluation exposes source text and standard-library imports without ambient filesystem, network, or environment access.

Stack: 2 of 2, depends on #8 (feature/independent-engine-runtime). Review and merge the runtime foundation first, then retarget this PR to main if GitHub does not do so automatically.

Validation: full pkl-core suite (1,797 passed, 3 skipped), including 18 interop tests; formatting and Javadoc checks. Coverage includes shared and independent engines, concurrent contexts, cross-context rejection, and snapshot lifetime.

Limits: named Pkl methods and class construction are not exposed; live foreign callbacks are unsupported. GraalPy integration, native-image builds, and performance benchmarks remain unverified. Usage examples and conversion semantics are documented in the pkl-core guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant