YAP 7.1.0
Old Call Cleanup

% call_cleanup/1 and call_cleanup/2 allow predicates to register code for execution after the call is finished More...

Detailed Description

% call_cleanup/1 and call_cleanup/2 allow predicates to register code for execution after the call is finished

Predicates can be declared to be fragile to ensure that call_cleanup is called for any Goal which needs it This library is loaded with the use_module(library(cleanup)) command % cleanup.yap Copyright (C) 2002 by Christian Thaeter % public interface: % :- fragile name/arity declares the predicate denoted by name/arity as fragile predicate Whenever such a fragile predicate is used in a query it will be called through call_cleanup/1 % call_cleanup(Goal) call_cleanup(Goal,CleanUpGoal) Goal will be called in a cleanup-context, where any registered CleanUpGoal inside of that context will be called when Goal is left, either by a fail, cut or exeption It is possible to nest cleanup contexts % on_cleanup(CleanUpGoal) registers CleanUpGoal to the current cleanup context CleanUpGoal's are executed in reverse order of their registration throws an exception if called outside of any cleanup-context % cleanup_all calls all pending CleanUpGoals and resets the cleanup-system to an initial state should only be used as one of the last calls in the main program % hidden predicates: most private predicates could also be used in special cases, such as manually setting up cleanup-contexts Read the Source


Class Documentation

◆ on_cleanup/1

class on_cleanup/1

on_cleanup(+ CleanUpGoal)

Any Predicate might registers a CleanUpGoal The CleanUpGoal is put onto the current cleanup context All such CleanUpGoals are executed in reverse order of their registration when the surrounding cleanup-context ends This call will throw an exception if a predicate tries to register a CleanUpGoal outside of any cleanup-context