% BEGIN LICENSE BLOCK
% Version: CMPL 1.1
%
% The contents of this file are subject to the Cisco-style Mozilla Public
% License Version 1.1 (the "License"); you may not use this file except
% in compliance with the License.  You may obtain a copy of the License
% at www.eclipse-clp.org/license.
% 
% Software distributed under the License is distributed on an "AS IS"
% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
% the License for the specific language governing rights and limitations
% under the License. 
% 
% The Original Code is  The ECLiPSe Constraint Logic Programming System. 
% The Initial Developer of the Original Code is  Cisco Systems, Inc. 
% Portions created by the Initial Developer are
% Copyright (C) 2006 Cisco Systems, Inc.  All Rights Reserved.
% 
% Contributor(s): 
% 
% END LICENSE BLOCK


\section{All Solutions }
     Built-ins to collect all solutions to nondeterministic goals.
     The implementation is in
     \begin{itemize}
     \item setof.pl
     \end{itemize}
     and is based on
     public domain code by Richard O'Keefe. The main change is the
     use of {\eclipse} bag-predicates to collect the solutions.

\section{Arithmetic }
Built-ins for arithmetic computations. Related code is in
     \begin{itemize}
     \item emu.c
     \item bip_arith.c
     \item bigrat.c
     \item intervals.c
     \end{itemize}
The actual arithmetic operations are implemented in functions that are
accessed via tag-index function tables, as described in section
\ref{secarith}.
The compiler (actually inlining transformations for is/2, >/2, etc)
flattens arithmetic expressions in sequences of predicate
calls, e.g.\ R is X+3*Y becomes
\begin{verbatim}
    *(3,Y,T), +(X,T,R)
\end{verbatim}
where T is a compiler-generated auxiliary variable. These predicates
are implemented in C via the function tables.  Expressions that are not
flattened by the compiler are interpreted by the predicate eval/2.


\section{Non-logical Variables, Arrays, Bags, Shelves and Stores }
Built-ins to store data across backtracking. All these relay on a single heap
copying routine to copy terms from the global stack (where they would be
discarded on backtracking) to the heap, where the memory is managed explicitly.
     \begin{itemize}
     \item bip_array.c - nonlogical variables and arrays, references
     \item bip_bag.c - bag built-ins
     \item bip_record.c - record built-ins
     \item bip_shelf.c - shelf built-ins
     \item bip_store.c - store built-ins
     \item property.c - heap copying routines
     \end{itemize}

\section{Control}
Built-ins and language constructs to control execution are mostly
recognised by the compiler and translated into specific abstract machine
instructions. Some of them employ auxiliary hand-written abstract machine
code sequences that are part of the runtime system. Files:
     \begin{itemize}
     \item emu.c (instructions)
     \item code.c (hand written code sequences)
     \end{itemize}

\section{Predicate Database and Compiler }
Built-ins for creation of handling of executable code (up to {\eclipse} 5.X).
     \begin{itemize}
     \item bip_db.c
     \item procedure.c
     \item section.c
     \item pass[234].c
     \item head.c
     \item body.c
     \end{itemize}

\section{Debugging }
Built-ins and commands related to debugging are implemented in
     \begin{itemize}
     \item emu.c
     \item bip_control.c
     \item tracer_tty.pl (console variant) and tracer_tcl.pl (gui variant)
     \end{itemize}

\section{Dynamic Predicates }
Built-ins to create and manipulate dynamic procedures are implemented in
     \begin{itemize}
     \item bip_db.c
     \item dynamic.c
     \end{itemize}

\section{Development Environment and Global Settings }
     Built-ins related to the development environment are implemented in
     \begin{itemize}
     \item bip_control.c
     \item bip_misc.c
     \end{itemize}

\section{Event Handling }
     Built-ins to handle events and interrupts are implemented in
     \begin{itemize}
     \item emu.c
     \item handlers.c
     \item error.c
     \end{itemize}

\section{External Interface }
     Built-ins to access functions and data from foreign languages are implemented in
     \begin{itemize}
     \item external.c
     \item embed.c
     \end{itemize}

\section{Character and Stream I/O }
Built-ins to open, manipulate and close I/O streams, and to
input and output characters or byte strings are found in
     \begin{itemize}
     \item io.c
     \item bip_io.c
     \end{itemize}

\section{Term I/O }
Built-ins for input/output of complex terms.
     \begin{itemize}
     \item bip_io.c
     \item lex.c (lexical analyser)
     \item read.c (parser)
     \item write.c (term writer)
     \end{itemize}

\section{Modules }
Directives and built-ins related to the module system.
     \begin{itemize}
     \item bip_module.c
     \item proc_desc.c
     \item property.c
     \end{itemize}

\section{Operating System }
Built-ins to access operating-system services.
Note the differences between UNIX and Windows style variants.
     \begin{itemize}
     \item bip_misc.c
     \item bip_io.c
     \item os_support.c
     \end{itemize}

\section{Strings and Atoms }
     Built-ins to create, convert and decompose strings and atoms.
     \begin{itemize}
     \item bip_strings.c
     \item bip_tconv.c
     \end{itemize}

\section{Advanced Control and Suspensions }
     Everything related to suspensions, priority- and data-driven control.
     \begin{itemize}
     \item emu.c
     \item bip_delay.c
     \end{itemize}

\section{Syntax Settings }
The setting that affect syntax are operators, structures, macros,
character classes.  Operators and macros are stored as functor
properties in the dictionary.  Structures are implemented on the
Prolog level and definition stored in a table. Character classes and
an number of option flags are part of a syntax descriptor that is stored
with each module.
     \begin{itemize}
     \item lex.c
     \item read.c
     \end{itemize}

\section{Comparing and Sorting }
Built-ins for symbolic term comparison and sorting. Files:
     \begin{itemize}
     \item bip_comp.c
     \end{itemize}
A central item is the routine compare_terms() which implements the standard
term order, a total order on all terms, including variables (as documented
for the compare/3 built-in). Order is primarily on term type, then on value.
Note that numbers of different types are therefore not in their numerical order.

As the core of all the sorting related builtins, a single implementation of
mergesort for lists is provided. The algorithm is natural merge, and
it takes advantage of preexisting order in the input list: subsequences
that are either in the correct order or in reverse order are detected.


\section{Term Manipulation }
     Built-ins to convert, compose, decompose and modify terms.
     \begin{itemize}
     \item bip_tconv.c
     \end{itemize}

\section{Type Testing }
     Meta-logical built-ins to test the type of terms.
     Most of these map to simple tag tests and are implemented
     inside the emulator.
     \begin{itemize}
     \item emu.c
     \end{itemize}
