Download 1 Introduction

Transcript
However, in contrast to conventional concurrent languages, each Oz thread is a
data-ow thread. Executing a statement in Oz proceeds only when all real data ow
dependencies on the variables involved are resolved. Oz has its roots in a paradigm
that is known as concurrent constraint programming [1].
2 Variables Declaration
We will restrict ourselves initially to the sequential programming style of Oz. You
can think of Oz computations as performed by one sequential process that executes
one statement after the other. We call this process a thread. This thread has access to
a memory called the store. It is able to manipulate the store by reading, adding, and
updating information. Information is accessed through the notion of variables, i.e.
a thread can access information only through the variables visible to it, directly or
indirectly. Oz variables are single-assignment variables. This notion is known from
many languages including data ow, and (concurrent) logic programming languages.
A single assignment variable has a number of phases in its lifetime. Initially it is
introduced and later it might be assigned a value, in which case the variable becomes
bound. Once a variable is bound it cannot itself be changed. However this does not
mean that you cannot model state because a variable, as you will see later, could
be bound to an object or a cell, which is statefull, i.e. the object can change its
content.
A thread executing the statement
local
X Y Z in S end
will introduce three variables X , Y and Z and execute S in the scope of these
variables. A variable normally starts with an upper case letter, possibly followed
by an arbitrary number of alphanumeric characters. Before the execution of S the
variables declared above will not have any associated values, i.e. the variables are
unbound. Any variable in an Oz program must be introduced, except for certain
pattern matching constructs to be shown later.
Another form of declaration is
declare
X Y Z in S
This is an open-ended declaration that makes X , Y and Z visible globally in S ,
including all statements the follows textually, unless overridden again by another
variable declaration of the same variables.
3 Primary Oz Types
Oz is a dynamically-typed language. Figure 1 shows the type hierarchy of Oz. Any
variable, if it ever gets a value, will be bound to a value of one of these types. Most
of the types seems familiar to experienced programmers, except probably Chunk,
Cell, Space, FDint and Name. We will discuss all of these types in due course.
For the impatient reader here are some hints. The chunck data type allows users
to introduces new abstract data types. Cell introduces the primitive notion of
2