The Mjølner System: Basic Libraries

The Mjølner System contains a series of basic libraries which contain the most important pattern definitions and useful basic facilities.

The Basic Patterns

The basic patterns are the object-oriented variants of the standard simple datatypes, such as char, boolean, integer and real. These patterns make it possible to treat e.g. integers as ordinary objects. The basic patterns also includes the Object patterns, which is the implicit superpattern for all patterns that have no explicit superpattern.

The Streams Patterns

A Stream is a generalization of internal and external text objects. An internal text object (Text) is a sequence (repetition) of chars with an associated position. An external text object (File) corresponds to a traditional text file. Stream, Text and File are organized in the following hierarchy:
 Stream: (# ... #);
   Text: Stream(# ... #);
   File: Stream(# ... #);
     UnixFile: File(# ... #);
     NtFile: File(# ... #);
     MacFile: File(# ... #);
The Stream pattern also allows you to identify a subrange of a Stream and manipulate this as a separate Stream - the "surrounding" Stream will be manipulated each time the substream is manipulated and vice versa.

As part of the interface to the operating system, the basic libraries also include patterns for accessing the directory structures of hierarchical file systems:

 Directory: (# ... #);
   UnixDirectory: Directory(# ... #);
   NtDirectory: Directory(# ... #);
   MacDirectory: Directory(# ... #);

Input and Output

The Stream pattern defines a number of input/output operations on the associated physical object: Operations such as put and get (dealing with a single character), putInt and getInt (dealing with integers), putLine and getLine (dealing with a complete text line) are standard for all streams. Extra libraries defines operations like putFormat and getFormat (for writing and reading arbitrarily formatted text sequences), putHex and getHex (dealing with hexadecimal numbers), etc.

The Container Patterns

The standard container datastructures are organized in the following inheritance hierarchy of patterns:
                     container
         _________________|__________________________________
         |             |            |	     |              |
     collection  arrayContainer  dictionary  list  sequentialContainer
   ______|_______                		 ___________|_______________
   |            |                		 |       |       |         |
multiset    hashTable            	       stack   queue   deque  prioQueue
   |
  set
 __|_____________________ 
 |                      |
 classificationSet   classificationSubSet
Container patterns are generic patterns in the sense that the element type of the elements kept in the container can vary between different container instances. MultiSet is an unstructured collection of element references, where duplicates are allowed. Set is like multiSet, except that duplicated are not allowed. ClassificationSet (and the accompanying classificationSubset) is used for dynamic classification of objects. HashTable implements a standard hash table datastructure. ArrayContainer is an abstraction of an element repetition, augmented with sorting operations Stack implements a stack datastructure. Queue implements a queue datastructure. Deque implements a double-ended queue datastructure. PrioQueue implements a priority queue datastructure. Dictionary is used for storing associations between two objects - a Key and a corresponding Entry. List implements a list data structure. Lists may be recursive (i.e. lists may have sublists).

Regular Expressions, Random Numbers, and Time

Libraries for dealing with regular expression matching, random number generation and formatted time strings are also included in the basic libraries.

The Process Patterns

The Process interface facilitates execution of subprocesses, communication between several independent processes, client/server architectures, and it is e.g. possible to establish communication between Unix and PC processes.

The Concurrency Patterns

The basic libraries defines various patterns for dealing with concurrency, synchronization and communication. These patterns are: system, semaphore, fork, monitor, port, restrictedPort, objectPort, qualifiedPort, conc, and alt.

The External Language Interface Patterns

To enable interfacing into external languages (such as C), the basic libraries defines the external, cStruct, externalRecord and cString patterns.

More Information

For further information, see
Mjølner System: Basic Libraries.
Mjølner System: Container Libraries.
Mjølner System: Process Libraries.