23.2 Porting programs to plain ECLiPSe
If you want to use ECLiPSe to do further development of your application,
it is probably advantageous to modify it such that it runs under plain
In the following we summarise the main aspects that have to be considered
when doing so.
In general, it is almost always possible to add to your program
a small routine that fixes the problem, rather than to modify
the source of the application in many places.
For example, name clashes are fixed more easily
by using the local/1 declaration
rather than by renaming
the clashing predicate in the whole application program.
- Due to lack of standardisation, some subtle differences in the
syntax exist between Prolog systems. See A.4
for details. ECLiPSe has a number of options that make it possible
to configure its behaviour as desired.
- ECLiPSe has the string data type which is not present in Prolog
of the Edinburgh family.
Double-quoted items are parsed as strings in ECLiPSe, while they are
lists of integers in other systems and when the compatibility
packages are used (cf. chapter 5.4).
- I/O predicates of the see and tell group are not built-ins
in ECLiPSe, but they are provided in the cio library.
Call lib(cio) in order to have them available (cf. appendix A).
Similarly for numbervars/3.
- In ECLiPSe, some built-ins raise events in cases where they just fail
in other systems, e.g., arg(1, 2, X) fails in C-Prolog, but
raises a type error in ECLiPSe.
If some code relies on such behaviour, it is best to modify it by
adding an explicit check like
..., compound(T), arg(N, T, X), ...
Another alternative is to redefine the arg/3 built-in, using
:/2 to access the original version:
:- local arg/3.
arg(N, T, X) :-
eclipse_language:arg(N, T, X).
A third alternative
is to define an error handler which will fail the predicate
whenever the event is raised. In this case:
my_type_error(_, arg(_, _, _)) :- !, fail.
my_type_error(E, Goal) :- error(default(E), Goal).
:- set_error_handler(5, my_type_error/2).
- As the ECLiPSe compiler does not accept procedures whose clauses
are not consecutive in a file, it may be necessary to add
directives if you want to compile such procedures.