Re: handling state the database way

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 02/17/2014 10:36 AM, Abdallah, Samer wrote:
> Searching for 'prolog continuation' as I write, I see that Jan has done some
> work with Tom Schrijvers on delimited continuations in Prolog, as as Ulrich
> Neumerkel. Is there any chance of this making it into SWI?

I'm not sure. Actually, the examples for carrying state can be
implemented differently as I've shown in various evaluations. Real
coroutining is a nice feature of delimited continuations. The proof of
concept was rather easily implemented, but this had several flaws in
handling meta-calling and dynamic predicates if these were retracted
while captured in a continuation. These problems did not hurt hProlog
because it has no dynamic predicates with real bodies (AFAIK) and it
does meta-calling differently. SWI-Prolog creates a chunk of executable
code for meta-calls that contain control structures. That is also not
easily captured in a continuation.

An alternative for state is to store state in the environment (stack).
That can be emulated using SWI-Prolog's stack inspection hacks (don't do
this at home :-). It is fundamentally simpler and a lot faster than
delimited continuations though.

Coroutining can be implemented using Paul Tarau's engines (or Torbjörn
Lager's pengines).  Of course, these behave differently due to the
copying of goals to a new thread (engine).  As Paul showed, engines can
also be used to store state.

	Cheers --- Jan
_______________________________________________
SWI-Prolog mailing list
[email protected]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.