This chapter explains issues for writing portable Prolog programs. It was started after discussion with Vitor Santos Costa, the leading developer of YAP Prolog90http://yap.sourceforge.net/ YAP and SWI-Prolog have expressed the ambition to enhance the portability beyond the trivial Prolog examples, including complex libraries involving foreign code.
Although it is our aim to enhance compatibility, we are still faced
with many incompatibilities between the dialects. As a first step both
YAP and SWI will provide some instruments that help developing portable
code. A first release of these tools appeared in SWI-Prolog 5.6.43. Some
of the facilities are implemented in the base system. Others in the
library library(dialect.pl)
.
swi
for SWI-Prolog and yap
on YAP.
swi(Major, Minor, Patch, Extra)
:- if(Condition)
...:-
endif
is supported. See section
4.3.1.1.
__SWI_PROLOG__
when compiled
for SWI-Prolog and __YAP_PROLOG__
when compiled on YAP.
The exact behaviour of this predicate is still subject to discussion.
Of course, if Dialect matches the running dialect the
directive has no effect. Otherwise we check for the existence of
library(dialect/Dialect)
and load it if the file is found.
Currently, this file has this functionality: