Delimited continuations in Prolog: semantics, use, and implementation in the WAM

Tom Schrijvers, Bart Demoen, Benoit Desouter · Ghent University Academic Bibliography (Ghent University) · 2013

An implementation of a delimited continuations, known in the functional programming world, is shown in the context of the WAM, and more particular in hProlog. Three new predicates become available to the user: reset/3 and shift/1 for delimiting and capturing the continuation, and call_continuation/1 for calling it. The underlying low-level built-ins and modifications to the system are described in detail. While these do not turn continuations into first-class Prolog citizens, their usefulness is shown in a series of examples. The idea behind this implementation can be adapted to other Prolog implementations. The constructs are compared with similar ones in BinProlog and Haskell. Their interaction with other parts of Prolog is discussed.

Read the paper · More papers on PaperTik