|Did you know ...||Search Documentation:|
|Pack genutils -- prolog/delimcc.pl|
This module builds on the interface provided by reset/3 and shift/1 to provide higher level facilities, including multiple prompts (p_reset/3 and p_shift/2) and a more functional style shift operator with automatic reinstallation of the prompt in the signal handler with pr_reset/3.
reset/2 and p_reset/2 both return a value of type
cont(A) to describe
the status of the computation, where A is the type of the term that was
thrown by shift/1 or p_shift/2.
pr_reset/3 expects the shifted term to contain a handler predicate, which is
invoked immediately with the continuation as a unary predicate and is expected
to produce a result. Hence, pr_reset/3 never produces a
cont(A) ---> done; susp(A,pred) handler(A) == pred(pred(-A),-A).
None of these shift produce continuations that reinstall the control context that was created by the original reset. Hence, if the continuation is expecting to capture more continuations, it should be called inside another reset. pr_reset/3 does, however, resintall the context before calling the continuation handler, so the continuation can be called inside the handler, but if it is instead returned to the wider program context, the context should again be created before calling the continuation. There are other ways of handling the removal and replacing of contexts, as described by Shan (2004).
 Chung-chieh Shan. Shift to control. In Proceedings of the 5th workshop on Scheme and Functional Programming, pages 99â107, 2004.
The following predicates are exported, but not or incorrectly documented.