Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm rework #2825

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Wasm rework #2825

wants to merge 2 commits into from

Conversation

bakaq
Copy link
Contributor

@bakaq bakaq commented Feb 14, 2025

This reworks the Wasm API to match the Rust API and therefore be much more flexible (query iterators allowing continuous feedback and infinite leaf answers, actual term data representation instead of just strings, etc...). This was some of the trickiest Rust code I've ever wrote (self-referential structs, single threaded channels, etc...), but I managed to do all of it without using unsafe. If anyone has suggestions on how to do it better please tell me. If anyone has suggestions on how to make the interface more idiomatic for Javascript I would also like to hear it!

This is still very rough and needs polish (and documentation, which I intentionally deferred), but already works really well as is.

Non-goals for this PR:

  • Have a way to capture stdout like the removed eval_code, and some way to interface with stdin. This is needed for eventually running the CLI toplevel in Scryer Playground. Doing this properly depends on Callback streams for use as library #2799, and I will do that in another PR. Just having access to queries is already powerful enough for the vast majority of use cases.
  • Settle on a serialization. This would definitely have been easier to do if we had decided on a serialization (Term and LeafAnswer serde serialization #2707), but it doesn't depend on it.
  • WASI or pure Wasm. These are also applications of Wasm I think we should tackle eventually, but this PR is concerned specifically with embedding Scryer Prolog in Javascript (the browser and things like NodeJS). WASI doesn't need any special treatment interface-wise, and pure Wasm will come for free with ISSUE-2464: Make scryer prolog usable as a shared library for other programs #2464.

@bakaq bakaq marked this pull request as draft February 14, 2025 10:12
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