Skip to content

How can I implement a callback to Prolog from Rust? #1550

Answered by mthom
aarroyoc asked this question in Q&A
Discussion options

You must be logged in to vote

You'd have to implement separate system instructions for issuing the request to the server and awaiting the response, both as a matter of the WAM's design philosophy and because the borrow checker won't allow you to do otherwise. A blocking request-and-wait could be implemented as a single instruction but a non-blocking request needs at least two.

Scryer is a direct threaded interpreter. As such, there is only one call stack frame belonging to dispatch_loop at any given time. Co-routining between Prolog and Rust is not really a thing, that is, a Rust function can never cede execution to dispatch_loop, let it run for a time, and then return to the point where the function yielded control to

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@aarroyoc
Comment options

aarroyoc Jul 29, 2022
Author Sponsor

@triska
Comment options

@aarroyoc
Comment options

aarroyoc Jul 30, 2022
Author Sponsor

Answer selected by aarroyoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants