% LAST EDIT: Tue May  3 13:43:01 1994 by Juergen Exner (hektor!jue) 
% LAST EDIT: Tue Feb 15 17:37:14 1994 by Juergen Exner (hektor!jue) 
% LAST EDIT: Thu Oct 14 20:34:30 1993 by Juergen Exner (hektor!jue) 
% LAST EDIT: Tue Jan 12 16:37:24 1993 by Juergen Exner (hektor!jue) 
\chapter{The Standard Library}
\label{chap:lib}
\label{sec:predef}
\novice
Conceptually \opal\ offers no built-in data types. There are no
numbers, no texts, no complex data types like arrays or anything else
as is customary in other programming languages.

In \opal\ these issues are deferred to the standard library, which
offers a large number of simple as well as powerful data structures
and algorithms.
At the moment there are more then one hundred structures and the
number continues to  increase as new features are added to the library.

In this appendix we will give a short survey of the features
offered by the standard library. 
It won't be a complete guide, just a glance.
For more detailed information you should refer to the guide
``Bibliotheca Opalica'' \cite{Di}, the library itself
(in subdirectory \pro{.../lib}) and  to the online documentation
system ``olm''.

\medskip
The library has a two-dimensional structure with several naming
conventions. In general there are several auxiliary structures for
each data type, which offer additional operations for the data
type in question.
These conventions are straigthforward.
They are explained in \cite{Di} and should help to prevent the user
getting lost in the huge library.

\bigskip
The library is divided into five subsystems: Internal, Basic Types,
Functions, Aggregate Types and System.
In the following sections we provide a short overview of each of
these subsystems.


\section{Internal}
\label{denotations}
\novice There are only two  structures in this subsystem which are
of interest to the user: \pro{BOOL} and \pro{DENOTATION}. 

Because boolean values and denotations are essential for the compiler,
they are (in contrast to all theory) in fact not realized with library
structures but are built-ins of the compiler. 
The two structures \pro{BOOL} and \pro{DENOTATION} only ensure correct
management during compilation.

These two structures are always imported automatically.
Therefore these two structures cannot be substituted by user-written
structures as it is possible for all other structures.

Note: There is a second data type (called \pro{string}) for
representation of text beside denotations; see \ref{sec:aggrTypes} for
differences. 

\section{Basic Types}
\novice In this subsystem the customary data types are declared. This encompasses
natural and integral numbers, real numbers, characters and also some
additional operations for bools and denotations. 



\section{Functions}
\novice The subsystem \pro{Functions} contains several structures which
support the combination of functions in various ways, e.g.~for the
well-known function-composition, for iterating functions, for
combining 
predicates or for defining ordering relations on arbitrary data
types.


\section{Aggregate Types}
\label{sec:aggrTypes}

\novice In the subsystem \pro{Aggregate Types} a bunch of more or less complex
data types is defined. 
These range from the very familiar, like \pro{strings}, to the
extremely complex, e.g. arbitrary graphs.

In detail, there are
\begin{itemize}
\item products, which realize cartesian products with up to four dimensions;
\item unions, which realize disjoint unions with up to four data types;
\item sequences of arbitrary elements as the most frequently used data
  structure in functional programming;
\item strings as an alternative method for representing text; Strings
  could be thought of as sequences of characters, whereas denotations are
  more like arrays of characters. 
  You should use denotations if the text does not change very often
  (e.g.~for fixed messages), whereas strings are better if you are
  continually modifying the text.

  There are also structures to scan and to format strings.
\item sets of arbitrary elements; Sets could also be defined with
  predicates, which describe the members of the set or as bitsets
  which are fast but limited in size.
\item bags as sets with multiple elements;
\item maps as implementations of arbitrary mappings;
\item arrays as a special (and efficient) form of mappings with a
  domain restricted to natural numbers;
\item graph-like data structures; This subsystem is still under
  construction. At the moment there are only AVL-trees available.
\end{itemize}

\section{System}
\novice This subsystem consists of four part:
\begin{itemize}
\item Debugging offers some functions we hope you will never need;
\item Commands realize the basis for input and output;
\item Streams offer a simple communication protocol, which is independent form
  the operating system used;
\item Unix supports access to UNIX-specific features like file-system,
  environment and processes;
\end{itemize}



%\subsection{Basic Data Types}
%\label{denotations}
%The standard library contains several structures which implement
%simple data\-structures:
%\begin{description}
%\item[BOOL:] The Boolean values \pro{true} and \pro{false} and several
%      standard operations.
%\item[DENOTATION:] The data type \pro{denotation}, a method for
%  denoting arbitrary objects, see below.
%\item[Nat:] Natural numbers with the usual operations.
%\item[Int:] Positive and negative numbers with usual operations and
%  conversions between \pro{int} and \pro{nat}.
%\item[Real:] The usual floating point numbers with their operations
%  and conversions between \pro{real} and \pro{int}.
%  Remember that floating point numbers are only an approximation of the
%  mathematical real numbers.
%\item[Char:] All characters, but based on the numerical
%  ASCII-representation.
%Offers also some constants and classification functions,
%e.g.~\pro{blank}, \pro{newline}, \pro{digit?}, \pro{lower?} etc.
%\item[PrintableChar:] Defines constants for all printable
%  ASCII-characters.
%\end{description}
%Denotations are just  lists of characters. They can't be modified and
%their only business is to be converted into other data types.
%They are very important as denotations are the only possibility for
%denoting arbitrary objects.  
%For any data type you could write conversion functions which convert
%denotations to the required data type, thus a denotation can be used
%to represents objects of any data type.
%
%For the standard data types like numbers, characters and also strings,
%these conversion routines are included in the corresponding
%structures (usually named ``\pro{!}'').
%This is also the appropriate solution for denoting arbitrary numbers,
%as the library structures only offer very few---often used---numbers
%as predefined constants. 
%
%
%\section{Complex Data Structures}
%The more complex data structures  are in general parameterized,
%e.g.~sequences, sets, bags, arrays and AVL-trees.
%We won't discuss them in detail.
%
%In general there is more than one structure for one abstract data
%type, such as sets.
%For technical reasons the structure parameter has to be
% enlarged with a second and even a third parameter sort for several
% higher order  functions like apply-to-all, filter, reduce and zip.
%For details you should read ``The \opal-Library''.
%
%Mappings (which belongs to this group too) can be used to define
%functions with an finite domain explicitly by enumerating all values.
%
%
%\section{Input and Output}
%Input and output are realized in \opal\ with continuations.
%The library structures for I/O contain the definition of the sort
%\pro{com} for commands, several functions for string oriented I/O,
%combining commands, checking the success of I/O-operations and, finally,
%low-level binary I/O.
%
%
%\section{Unix}
%The library also offers access to several Unix-specific features such as
%the environment, creating and manipulating processes and dealing with
%sockets.
%
%
%\section{Auxiliary Structures}
%There are also structures for combining up to four sorts in one data
%type, for function composition and even for control structures, so
%that an imperative approach is simulated.

% Local Variables: 
% mode: latex
% TeX-master: "tutorial"
% End: 
