ISO Standard & Portability

ISO/IEC 13211-1:1995 (core) with corrigenda (2007, 2012, 2017); part 2 covers modules (rarely implemented as specified).

45.1 The ISO standard

ISO/IEC 13211-1:1995 (core) with corrigenda (2007, 2012, 2017); part 2 covers modules (rarely implemented as specified). It defines syntax, built-ins, error terms, flags, and streams.

45.2 SWI-Prolog 7+ differences from ISO

list of codes (flag-dependent) '[|]' functor special constant ≠ '[]' bounded or unbounded (implementation-defined)

Use swipl --traditional for classic behaviour.

45.3 Writing portable code

Stick to ISO built-ins and widely available libraries (lists, apply, clpfd/clpz).

Use chars for text (:- set_prolog_flag(double_quotes, chars).).

Use conditional compilation for system-specific parts:

Logtalk offers a portability layer and OOP across ~a dozen Prolog systems.

Check conformity with Ulrich Neumerkel's ISO conformity assessment tables.

:- if(current_prolog_flag(dialect, swi)).
:- use_module(library(clpfd)).
:- elif(current_prolog_flag(dialect, scryer)).
:- use_module(library(clpz)).
:- endif.

45.4 Prolog flags

?- current_prolog_flag(bounded, B).
?- set_prolog_flag(double_quotes, codes).
?- set_prolog_flag(occurs_check, error).
?- set_prolog_flag(answer_write_options, [max_depth(0)]).   % print full answers
?- set_prolog_flag(unknown, error).
?- set_prolog_flag(prefer_rationals, true).