Next: I/O Redirection
Up: Libraries
Previous: ISO Standard Prolog Compatibility
  Index
Subsections
C-Prolog Compatibility Package
One of the requirements during the development of ECLiPSe has been the aim
of minimising the work required to port
C-Prolog programs to ECLiPSe. To this end,
many of the non standard predicates in C-Prolog have also been included
in ECLiPSe. It is of course impossible to achieve total
compatibility between the two systems. To assist in making the changes
necessary to run a C-Prolog program on the current version of
ECLiPSe, this appendix describes the predicates
available in the C-Prolog compatibility library and it summarises
the principal differences between ECLiPSe Prolog and C-Prolog.
Most of the C-Prolog predicates are also ECLiPSe built-in
predicates and so they can be always accessed.
Please note that this appendix does not detail the functionality
of C-Prolog, refer to the C-Prolog documentation for this information.
The C-Prolog compatibility package can be accessed by issuing the directive
:- use_module(library(cprolog)).
The effect of the compatibility library is local to the module where it
is loaded (except for the redefinition of some global event handlers).
The directive must therefore be given in every module that wants to
use the compatibility mode.
The C-Prolog compatibility package includes the cio and the
scattered library.
The following predicates are available in the compatibility package.
They are exported from the module cprolog and automatically imported
by use_module/1 or lib/1.
- consult/1
- reconsult/1
-
The above two are implemented by simply calling the ECLiPSe predicate
compile/1. By default
all compiled procedures are static.
Procedures on which assert/1 etc. will be applied,
have to be declared as dynamic using dynamic/1.
The notation [-File] for reconsult/1 is not
supported.
- current_functor/2
-
- current_predicate/2
-
- db_reference/1
-
- erased/1
-
- get/1
-
This is similar to the ECLiPSe predicate get/1, but control characters
and blank spaces are skipped.
- get0/1
-
- fileerrors/0
-
- heapused/1
-
Needed for evaluating heapused in arithmetic expressions.
It returns the sum of code heap and general heap usage.
- instance/2
-
Note that this compatibility predicate redefines the ECLiPSe builtin
of the same name but different meaning (which is no longer available
in C-Prolog mode).
It is implemented using the ECLiPSe predicate referenced_record/2.
- leash/1
- The ECLiPSe leash built-in provides more functionality than the
C-Prolog equivalent.
- log/2
-
- log10/2
-
These are not predicates in C-Prolog (arithmetic functors), but in ECLiPSe
they are needed for evaluating log/1 and log10/1 in arithmetic expressions.
- nofileerrors/0
-
- primitive/1
-
- prompt/2
-
- put/1
-
This is similar to the ECLiPSe predicate put/1, but it first applies
arithmetic evaluation to its argument.
- sh/0
-
- see/1
-
- seeing/1
-
- seen/0
-
- skip/1
-
- tab/1
-
- tell/1
-
- telling/1
-
- told/0
-
The predicates of the see/tell family are defined in the
cio library and can also be loaded independently.
- ttyput/1
- corresponds to the DEC-10 Prolog predicate
The following C-Prolog predicates are not available in ECLiPSe,
or the corresponding predicates have a different semantics:
- assert/2
-
- asserta/2
-
- assertz/2
-
- clause/3
-
ECLiPSe does not support database references for clauses.
- expand_term/2
-
This is not supported. ECLiPSe provides the macro facility for
transforming input terms (see chapter 13).
- 'LC'/0
-
- 'NOLC'/0
- These are not supported in ECLiPSe.
The following differences remain even with the compatibility package:
- Database References
- ECLiPSe provides database references only for terms in the
indexed database, not for program clauses.
- Numbers
- C-Prolog has a tendency to ``prefer'' integers over real numbers.
For instance, under C-Prolog when the call X is 4.0/2.0
is made, X is instantiated to an integer. This behaviour does
not occur in ECLiPSe. The order of integers and reals in the standard
order is different.
- Operators
- In C-Prolog there is a bug regarding the operator not --
it binds closer than its precedence declaration.
- Strings
- Strings are simulated in C-Prolog by lists.
Under C-Prolog mode, ECLiPSe provides this functionality -- double-quoted
strings are parsed as lists of integers.
This can cause confusion when pure ECLiPSe predicates are used
in C-Prolog mode, e.g. substring/3 will not accept double-quoted
items, since they are lists, not ECLiPSe strings.
The built-in string_list/2 converts between both representations.
The list below describes the syntax differences between ECLiPSe and C-Prolog.
The following C-Prolog properties are simulated by the compatibility package:
- A blank is not allowed between the functor and the opening bracket.
- single (resp. double) quote must be doubled between single (resp.
double) quotes.
- newline is allowed between quotes.
$
is a normal character.
The following properties of original C-Prolog are not simulated
by the compatibility package:
- the symbol
|
is not an atom.
- a clause can not be ended by end of file.
- based integers are not accepted.
- comments are not a delimiter (just ignored).
{}
is not an atom.
[]
can not be a functor.
Next: I/O Redirection
Up: Libraries
Previous: ISO Standard Prolog Compatibility
  Index
1999-08-06