[ Directives | Reference Manual | Alphabetic Index ]

if(+Goal)

Conditional compilation directive.
Goal
Goal to be tested

Description

The compiler and other source-processing tools recognise the conditional compilation directives if/1, elif/1, else/0 and endif/0. The first two take a goal as their argument, and parts of the program source can be included or excluded depending of the satisfiability of that goal.

Note that these directives are the only ones that are not treated as predicate separators and can be placed around individual clauses of a predicate.

Modes and Determinism

Examples

    :- if(get_flag(hostarch,"i386_nt")).

	...Windows-specific code...

    :- elif( (get_flag(version_as_list,Version), Version @>= [6,0]) ).

	...code for version 6.0 and later...

    :- else.

	...alternative code...

    :- endif.
    

See Also

elif / 1, else / 0, endif / 0, library(source_processor)