Run-time checking of assertionsAuthor(s): Edison Mera.
This package provides a complete implementation of run-time checks of predicate assertions. The program is instrumented to check such assertions at run time, and in case a property does not hold, the error is reported. Note that there is also an older package called rtchecks, by David Trallero. The advantage of this one is that it can be used independently of CiaoPP and also has updated functionality.
There are two main applications of run-time checks:
- To improve debugging of certain predicates, specifying some expected behavior that is checked at run-time with the assertions.
- To avoid manual implementation of run-time checks that should be done in some predicates, leaving the code clean and understandable.
The run-time checks can be configured using prolog flags. Below we itemize the valid prolog flags with its values and a brief explanation of the meaning:
- no : Instrument rtchecks using call to library predicates present in rtchecks_rt.pl, nativeprops.pl and basic_props.pl. In this way, space is saved, but sacrifying performance due to usage of meta calls and external methods in the libraries. Default.
- yes : Expand library predicates inline as far as possible. In this way, the code is faster, because its avoids metacalls and usage of external methods, but the final executable could be bigger.
- rtchecks_asrloc Controls the usage of locators for the assertions in the error messages. The locator says the file and lines that contains the assertion that had failed. Valid values are:
- rtchecks_predloc Controls the usage of locators for the predicate that caused the run-time check error. The locator says the first clause of the predicate that the violated assertion refers to.
- no : Do not show the stack of predicates that caused the failure
- predicate: Show the stack of predicates that caused the failure. Instrument it in the predicate. Default.
- literal : Show the stack of predicates that caused the failure. Instrument it in the literal. This mode provides more information, because reports also the literal in the body of the predicate.
Controls if run time checks must abort the execution of a program (by raising an exception), or if the execution of the program have to continue.
Note that this option only affect the default handler and the predicate call_rtc/1, so if you use your own handler it will not have effect.