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

scryper-prolog as a library #225

Closed
uraj opened this issue Oct 29, 2019 · 19 comments
Closed

scryper-prolog as a library #225

uraj opened this issue Oct 29, 2019 · 19 comments

Comments

@uraj
Copy link

uraj commented Oct 29, 2019

I was wondering if it's possible to use scryper-prolog as a library such that it can be embedded into other applications as a backend for solving certain logic puzzles.

@triska
Copy link
Contributor

triska commented Oct 29, 2019

Is there a reason to use a library for this? One very good solution for such use cases is often to use well-established interface mechanisms such as pipes, files or sockets to communicate between the two processes. This allows easier coupling and debugging, and also keeps the core small.

One important feature to easily communicate between processes is described in #187 (update: and it is now already available). With this command line option, you can dynamically specify a goal, and get the output via standard mechanisms directly from the Scryer process.

@uraj
Copy link
Author

uraj commented Oct 29, 2019

I'm considering using Prolog inside SGX, a hardware feature available for some Intel CPUs. In SGX mode, performing I/O is expensive and can be extremely insecure. That's why a library is more desired.

@mthom
Copy link
Owner

mthom commented Oct 30, 2019

You could always package the machine submodule as a library, sure. I'm not thrilled with the way expansions and the toplevel interaction are currently handled, though. I would want to revise them to be faster and more Prolog- rather than Rust-based, as they now are. Their current form is a holdover from the early days of the project.

@Immortalin
Copy link

Immortalin commented Nov 8, 2019

I am considering using scryer as a parser frontend for a JIT interpreter (the parser is written in prolog). Would be great if it's embeddable.

@hashedone
Copy link

I also think this is a great idea - I would like to use some prolog-like machine for type resolution for experimental language (and this is exactly what Rust is doing with chalk, so it's tested idea). Communication via pipes/sockets kills performance.

@shonfeder
Copy link

I came in search of this this too.

@ghost
Copy link

ghost commented Feb 25, 2021

A start solution would be to write a src/lib.rs with all the modules, then the visibility/privacy problem can be solved later with an example/reason to use a data structure, function, ...

@shonfeder
Copy link

Yeah, that'd be a great start! I wonder if it would also make sense to fold #765 and #570 and this into a single issue (or, rather just pick one and close the other two?) That'd would help the conversation around this be less fragmented.

@shonfeder
Copy link

In case it's useful context, I was considering using an embedable prolog as an alternative to sqlite (nice properties, like being able to write the database to a file in a readable way, and commit that to git, easily defining transitive closures, etc.). Of course, I could communicate through system calls, and manually implement de/serialization for data etc., but that's more over-head and requires an external dependency.

@ghost
Copy link

ghost commented Feb 25, 2021

Making a new issue to track the progress once all the others are closed is a possibility to better organize. For now the library doesn't exist yet.

@Immortalin
Copy link

And a two-way FFI would be very useful too.

@XVilka
Copy link
Contributor

XVilka commented Aug 20, 2021

A heads up for anyone subscribed to this issue - the initial work is here #838

@peschue
Copy link

peschue commented Apr 21, 2022

@triska I performed some initial experiments to communicate via scryer-prolog via STDIO or TTY - in both cases I encountered some difficulties, one case might even be a bug (the panic that happens with STDIO) see details here: #1413

@triska
Copy link
Contributor

triska commented Apr 21, 2022

@peschue: If Scryer crashes, then this is definitely a mistake somewhere in the code, please consider filing it as an issue with a minimal example, which ideally only needs a shell invocation or pipe on the command line. Thank you a lot!

@peschue
Copy link

peschue commented Apr 21, 2022

@triska I created issue #1439 for this.

@triska
Copy link
Contributor

triska commented Jul 12, 2023

There is a very promising contribution with the potential to resolve what remains of this issue: #1880.

Please try it and comment if possible!

@triska
Copy link
Contributor

triska commented Nov 22, 2023

@uraj: #1880 is now merged and I think it solves this issue. If it solves the issue for you, could you please consider closing it? Thank you a lot!

@uraj
Copy link
Author

uraj commented Nov 22, 2023

@triska I think this works. Thanks everyone for working on this over the years. Closing.

@uraj uraj closed this as completed Nov 22, 2023
@jjtolton
Copy link

jjtolton commented Aug 5, 2024

I can't tell if this has already been done or not, but I wasn't able to figure it out, so I hacked together some bindings that make it fairly straightforward to use scryer as a shared library: #2465

This might be a sequel to #1880, but I'm not really sure.

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

No branches or pull requests

9 participants