Generic Cut Actions for External Prolog Predicates
Tiago Soares, Ricardo Rocha and Michel Ferreira
January 2006
Abstract
An interesting feature of current Prolog systems is the ability to
define external Prolog predicates that can be written in other
languages. However, an important drawback of these interfaces is the
fact that they lack some important features necessary to improve both
the efficiency and the transparent integration of the Prolog system
and the external predicates. Such an example is the
cut
operation. This operation is used quite often in Prolog programs,
both for efficiency and semantic preservation. However, its use after
a call to an externally defined predicate can have undesired
effects. For example, if we have a pending connection to another
application, or if we have memory blocks allocated by an external
predicate, when a cut operation occurs, we may not be able to perform
generic destruct actions, such as closing the pending connection or
freeing the unnecessary memory. In this work, we propose an extension
of the interface architecture that allows to associate generic
user-defined functions with external predicates, in such a way that
the Prolog engine transparently executes them when a cut operation
occurs. We describe the implementation details of our proposal in the
context of the Yap Prolog system.
Bibtex
@InProceedings{soares-padl06,
author = {T. Soares and R. Rocha and M. Ferreira},
title = {{Generic Cut Actions for External Prolog Predicates}},
booktitle = {Proceedings of the 8th International Symposium on Practical Aspects of Declarative
Languages (PADL 2006)},
pages = {16--30},
number = {3819},
series = {LNCS},
publisher = {Springer},
editor = {P. Van Hentenryck},
month = {January},
year = {2006},
address = {Charleston, South Carolina, USA},
}
Download Paper
PDF file
Springer