Objects, processes and communication
\label{des/intro/lang}
Objects
play a central role in DLP, both as a means
for modularization and in providing protection for (local)
data.
Non-logical variables may be used to store the data encapsulated
by an object.
The clauses defined for an object act as methods, in that they
have exclusive access to these data. \n
Apart from clauses for methods, so-called constructor
clauses may be declared that specify the own activity of an object.
An object declaration in DLP is of the form
object name {
var variables.
constructor clauses
method clauses
}
Constructor clauses
are used when creating a new instance
of a declared object,
to start the own activity of
the newly created object.
Objects without constructor clauses are passive objects,
without activity of their own.
Each instance of an object has private copies of
the declared non-logical variables.
Inheritance
in DLP is static.
When in a declaration the name of the object is followed
by one or more object names, as in name : base,
then both the non-logical variables and the clauses
of the object base are copied into (each instance of) the
object name.
Processes
come into existence on two occasions.
When an object is created a constructor process is started,
executing the own activity of an object.
When an object receives a method call, a process is created for
handling the rendez-vous, that is for evaluating the goal and
to return the answer substitutions to the invoking process.
Both constructor processes and processes evaluating a goal
are sequential Prolog processes.
A method call may result in multiple answer substitutions.
Backtracking over these answer substitutions
produced in a rendez-vous is done lazily,
initiated by the invoking process.
We call this backtracking global since multiple processes
are involved.
An object may state its willingness to answer a method call
by means of an accept statement.
When an object is not willing to answer a method call,
the evaluation of the goal is suspended until the object
is willing to do so.
The language DLP
is an extension of Prolog with a number
of special forms for dealing with non-logical variables,
object creation and for engaging in a rendez-vous.\ftn{
We treat here only the subset of DLP that
we consider most important.
An overview of DLP is contained in chapter \ref{des/dlp}.
} \n
The special forms include:
x := t - to assign t as a value to the non-logical variable x
- to create a new active instance of c, evaluating
- to call the method of object O
- to answer one of the methods
In the list above t stands for a term, x for a non-logical variable,
O for a logical variable, c for an object name, and
for method names.
Each occurrence of a non-logical variable x
is reduced to the value of x, unless it occurs on the
left hand side of an assignment.
We also support the simplification of arithmetical
expressions.
The evaluation of results, apart from the
creation of a new instance of object c for
which the constructor is evaluated, in binding O
to a pointer to the object.
Communication
takes place by means of a (synchronous) rendez-vous.
A method call is of the form ,
where O must be bound to an object.
When the object is willing to accept the method, s
indicated by the occurrence of a goal ,
a process is created for evaluating the call.
The calling process waits until it receives an answer,
or a message of failure.
Since non-logical (instance) variables may be assigned values to,
no new evaluation process is started for the object,
when the call is accepted, until the first answer or failure is
delivered.
While backtracking over alternative answer substitutions,
other method calls may become active.
The distinction between objects and processes is
necessitated by the possibility of
global (distributed) backtracking.
When only local backtracking would be
allowed, the evaluation of
a method call could be done by the
object itself.
An example
of an object is given in the following declaration.
.ds ctr.pl
The use of such a counter is illustrated by the goal
:-
O = new(ctr()),
O!inc(),
O!value(X).
where a counter is created
that is subsequently asked to answer the method calls
and .
Evaluating the goal results in the creation of
a new instance of the declared object, evaluating the constructor.
The constructor of the counter states that the object is
prepared to answer any call, indefinitly.
The DLP target machine
is assumed to be a parallel processor
consisting of a limited number (less than 100, say)
of processor nodes
that are connected with each other by a packet switching network,
in such a way that the distance between each node never
exceeds a fixed number (3 or 4) of intermediate nodes.
For reasons of optimal utilization such machines are considered
to support coarse grain parallelism, which means that the ratio of
communication and computation must be in favor of the latter.
For effectively using such a processor we have included
facilities for the allocation of objects and processes.