Delimited control is a powerful mechanism for programming language extension which has been recently proposed for Prolog (and implemented in SWI-Prolog). By manipulating the control flow of a program from inside the language, it enables the implementation of powerful features, such as tabling, without modifying the internals of the Prolog engine. However, its current formulation is inadequate: it does not capture Prolog's unique non-deterministic nature which allows multiple ways to satisfy a goal. This paper fully embraces Prolog's non-determinism with a novel interface for disjunctive delimited control, which gives the programmer not only control over the sequential (conjunctive) control flow, but also over the non-deterministic control flow. We provide a meta-interpreter that conservatively extends Prolog with delimited control and show that it enables a range of typical Prolog features and extensions, now at the library level: findall, cut, branch-and-bound optimisation, probabilistic programming,...
翻译:限制控制是最近为Prolog(并在SWI-Prolog中实施)提出的一个强有力的语言扩展编程机制。它通过从语言内部操纵一个程序的控制流程,使得能够实施强大的功能,如制表,而不修改Prolog引擎的内部。然而,它目前的配方不够:它没有捕捉Prolog的独特的非决定性性质,这种特性允许多种方式实现一个目标。本文完全包含了Prolog的非决定性特性,并有一个新的界面,用于分解的限定控制,使程序员不仅能够控制顺序(连接)控制流程,而且能够控制非定序控制流程。我们提供了一种元式解释器,保守地扩展Prolog,加以限定控制,并表明它允许一系列典型的Prolog特征和扩展,现在在图书馆一级:查找、切割、分节和分界的优化、概率性编程,...