YAP 7.1.0

Conditional compilation builds on the same principle as term_expansion/2 , goal_expansion/2 and the expansion of grammar rules to compile sections of the source-code conditionally. More...

Detailed Description

Conditional compilation builds on the same principle as term_expansion/2 , goal_expansion/2 and the expansion of grammar rules to compile sections of the source-code conditionally.

One of the reasons for introducing conditional compilation is to simplify writing portable code

Note that these directives can only be appear as separate terms in the input Typical usage scenarios include:

Load different libraries on different dialects

Define a predicate if it is missing as a system predicate

Realise totally different implementations for a particular

part of the code due to different capabilities

Realise different configuration options for your software.
:- if(test1).
if.
:- elif(test2).
elif.
:- elif(test3).
elif.
:- elif.
elif.
:- elif.
elif(+ Goal)
if( : Goal)

Class Documentation

◆ if/1

class if/1

if( : Goal)

Compile subsequent code only if Goal succeeds For enhanced portability, Goal is processed by expand_goal/2 before execution If an error occurs, the error is printed and processing proceeds as if Goal has failed

◆ elif/1

class elif/1

elif(+ Goal)

Equivalent to :- else :-if(Goal) ... :- endif In a sequence as below, the section below the first matching elif is processed, If no test succeeds the else branch is processed