Body Conversion

Body conversion converts a goal of the form X where X is a variable, into a goal of the form call(X). And goals which are not of the form X where X is a callable are rejected by this conversion. Body conversion is in effect when clauses are asserted, either dynamically or statically. The effect can be seen by the following example. In the static rule for the predicate p/0 the variable X will be wrapped via a call/1:

Example
?- [user].
p :- q(X), X.
^D
?- listing.
p :-
    q(X),
    call(X).

Body conversion is also in effect when goals are executed, either directly or deferred via me-ta-arguments. The body conversion can be switched off via the flag sys_body_convert. The flag only affects the body conversion for the Prolog session queries, for the Prolog text clauses and for the Prolog text directives. The dynamic clause assertions and the deferred meta-arguments are not affected by the flag, these places will still do body conversion.

The body conversion is table driven. The meta-predicate declarations and determine how arguments are traversed. The predicate properties sys_body/0 and sys_rule/0 will indicate that the meta-predicates should be traversed during body conversion respectively rule conversion. To facilitate the declaration the predicate sys_neutral_predicate/1 allows defining dictionary entries that are not yet completely defined.

The following body conversion predicates are provided:

:- A:
The predicate cannot be executed and exists only to configure the body conversion table.
A :- B:
The predicate cannot be executed and exists only to configure the body conversion table.
A, B: [ISO 7.8.5]
The predicate succeeds whenever A and B succeed. Both goal arguments A and B are cut transparent.
call(A): [ÍSO 7.8.3]
The predicate succeeds whenever A succeeds. The goal argument A is converted before calling.
The following Prolog flags for body conversion are provided:
style_check:
The legal values are on and off. The flag indicates whether singleton variables are checked during consult or not. The default value is on. The value can be changed.

Kommentare