This article helps you skip the first chapter of Concepts, Techniques, and Models of Computer Programming.

Mozart Oz Shortcuts

C-x C-f Read a file into a new editor buffer C-x C-s Save current buffer into its file C-x i Insert file into the current buffer

C-. C-l Feed current line C-. C-r Feed current selected region C-. C-p Feed current paragraph C-. C-b Feed current buffer C-M-x Feed current paragraph

C-. h Halt the run-time system (but keep the editor) C-x C-c Halt the complete system

C-. e Toggle the emulator window C-. c Toggle the compiler window C-x 1 Make current buffer fill the whole window

C-g Cancel current command

The Oz Base Environment

Official Tutorial

System Modules

The Mozart Standard Library

The Mozart Compiler

Mozart 2

Oz Features

  • OO: state, abstract data types, classes, objects, and multiple inheritance. A class is essentially a record that contains the method table and attribute names. An object is essentially a special record having a number of components (object’s class and reference of a cell holding the object’s state).

  • FP: conposition syntax, lexical scoping. All entity is first-class, including threads and classes.

  • Logic and Contriant: logic variables, disjunctive constructs, and programmable search strategies.

  • Concurrent: each Oz thread is a dataflow thread. A port is an asynchronous channel that supports many-to-one communication.

  • Distribution: network-tarnsparent and language security.

  • Lexical Scope, Dynamically-typed, Strong Type, Single-assignment Variable,

The Kernel Language


Variables’s first letter is caplital. aa represents Atom type.

X = f(l1:Y1 ... ln:Yn) % Record
X = <number>
X = <atom>
X = <boolean>
{NewName X}
X = Y


proc {X Y1 ... Yn} S1 end
{X Y1 ... Yn} % Apply


{NewCell Y X}
Y=@X % Read cell
X:=Y % Update cell
{Exchange X Y Z} % Update cell


local X1 ... Xn in S1 end
declare X1 ... Xn in S1 % Another way to introduce variables.

Control Flow:

if B then S1 else S2 end


thread S1 end


try S1 catch X then S2 end
raise X end


Primary Oz Types


  • Number:

representation of numbers:

0300 % Octal starts with 0
0xad % hexadecimal starts with 0x or 0X
~3.14159 % Minus
&0 % 48. Standard ISO 8859-1 coding.
  • Name:

Anonymous unique unforgeable tokens. The only way to create a name is by calling the procedure {NewName X} where X is assigned a new name that is guaranteed to be worldwide unique.

  • Atom:

Literals start with low-case letters. No internal structures. Lexicalgraphic ordered.

  • Bool:

ture, false

  • Unit:


  • Record:
tree(key: I value: Y left: LT right: RT)
  • Tuple:

Tuples are connected by #.

'#'(1 2 3)
'#'() % An empty tuple.
  • List

Lists are connected by |.

[1 2 3] % Closed list
1|2|X % tail is X
"OZ 3.0" % String
[79 90 32 51 46 48] % "OZ 3.0"
[&O &Z &  &3 &. &0] % "OZ 3.0"
  • Virtual Strings:

A virtual string is a special tuple that represents a string with virtual concatenation, i.e. the concatenation is performed when really needed. Virtual strings are used for I/O with files, sockets, and windows. All atoms, except nil and ‘#’, as well as numbers, strings, or ‘#’-labeled tuples can be used to compose virtual strings. Here is one example:

123#"-"#23#" is "#100  % represents "123-23 is 100"
  • Chunk:

New abstract data types.

  • Cell:

Primitive notion of state-container and state modification.

  • Space:

Advanced problem solving using search techniques.

  • FDInt:

Finite domain that is used frequently in constraint programming, and constraint satisfaction.


== returns ture iff their structures and contents are the same.

Control Flow

if B1 then S1 elseif B2 then s2 else S3 end

if B1 then S1 
else if B2 then S2
    else S3 end

case E 
of Pattern_1 then S1 
[] Pattern_2 then S2 
[] ... 
else S 

Other keywords: andthen, orelse

Functions and Procedures

fun {F X1 ... Xn} S E end
proc {F X1 ... Xn R} S R=E end

Pattern Matching

TreeIn= tree(k v t1 t2)
local tree(K1 V1 T1 T2)= TreeIn in ... % then K1 represents k, etc.


The keyword functor are used to support module specification.

   proc {Append ... }  ... end 
   proc {MergeSort ...} ... end 
   proc {Sort ... } ... {MergeSort ...} ... end 
   proc {Member ...} ... end 


Stateful Data Types

Classes and Objects

Objects and Concurrency

Logic Programming