Using compatibility language dialects

## 23.1 Using compatibility language dialects

- ISO Prolog
- Compiler versus interpreter

The ECLiPSe compatibility language dialects are the fastest way to get a program running that was originally written for a different system. The dialects are implemented as libraries. The module system makes it possible for different application modules to use different language dialects.

To use a particular language dialect, prefix your program with a module/3 directive that specifies the desired language dialect, for example

        :- module(mymodule, [], iso).

Here, the last argument of the module/3 directive indicates the language (the default being eclipse_language). It is not advisable to use `:-lib(iso)` or `:-ensure_loaded(library(iso))` within an eclipse_language module, because this would lead to import conflicts between the different versions of built-in predicates.

Examples of supported language dialects are

- ISO Standard Prolog (iso_strict, iso and iso_light).
- C-Prolog (cprolog), one of the oldest and most influential Prolog implementations.
- Quintus Prolog (quintus), an early influential commercial system.
- SICStus Prolog (sicstus), an academic and commercial system based on Quintus.
- SWI Prolog (swi), a popular Prolog with large user base.

See the Reference Manual for details on the compatibility provided by the language dialects. The language dialects are just modules which provide the necessary code and exports to emulate a particular Prolog dialect. This module is imported instead of the default eclipse_language dialect which provides the ECLiPSe language. The source code of the language dialect module is provided in the ECLiPSe library directory. Using this as a guideline, it should be easy to write similar packages for other systems, as long as their syntax does not deviate too much from the Edinburgh tradition.

For quick experiments with a language dialect, ECLiPSe can be started with a different default_language option (see appendix D), e.g.

        % eclipse -L <dialect>

This will give you a toplevel prompt in the given language dialect. The same effect can be achieved by setting the ECLIPSEDEFAULTLANGUAGE environment variable to the name of the chosen dialect.

### 23.1.1 ISO Prolog

The ISO Prolog standard [1] is supported in three variants:

- The iso_strict dialect provides an implementation of ISO Standard Prolog and complies strictly with ISO/IEC 13211-1 (Information Technology, Programming Languages, Prolog, Part 1, General Core, 1995) and the technical corrigenda ISO/IEC 13211-1 TC1 (2007), TC2 (2012) and TC3 (2017).
- The iso dialect provides an implementation of ISO Standard Prolog and in addition includes ECLiPSe functionality that does not conflict with the standard.
- The iso_light dialect provides the essence of ISO features without aiming for full conformance (in particular with respect to error handling), and may include ECLiPSe extensions that go beyond what the letter of the standard allows.

The specification of implementation-defined features stipulated by the standard can be found in the reference manual for iso_strict and iso.

### 23.1.2 Compiler versus interpreter

The following problem can occur despite the use of compatibility packages: If your program was written for an interpreter, e.g., C-Prolog, you have to be aware that ECLiPSe is a compiling system. There is a distinction between static and dynamic predicates. By default, a predicate is static. This means that its clauses have to be be compiled as a whole (they must not be spread over multiple files), its source code is not stored in the system, and it can not be modified (only recompiled as a whole). In contrast, a dynamic predicate may be modified by compiling or asserting new clauses and by retracting clauses. Its source code can be accessed using clause/1,2 or listing/0,1. A predicate is dynamic when it is explicitly declared as such or when it was created using assert/1. Porting programs from an interpreter usually requires the addition of some dynamic declarations. In the worst case, when (almost) all procedures have to be dynamic, the flag all_dynamic can be set instead.