Instructors' Guide


Introduction Terminology Expressions Control Objects Inheritance Technology Summary

Objects

The language DLP supports active objects with a state (expressed as the value of non-logical instance variables) and communication by rendezvous (which realizes message passing for active objects). See slide dlp-objects-1.

Additional statements

DLP



slide: DLP -- objects (1)

To support these features we need, in addition to terms and clauses, statements to assign terms to non-logical variables, a statement to create new active instances of an object (class), a statement to call a method for an object (which is essentially the invocation of a goal), and an accept statement that allows an active object to interrupt its own activity and accept the request to execute a method. When binding terms to logical variables or assigning terms to non-logical variables, simple rewriting rules are applied. Rewriting includes arithmetic simplification and string manipulation.

Computation model -- distributed logic

objects -- state + methods
processes -- to evaluate goals
communication -- backtrackable rendezvous

slide: DLP -- objects (2)

The computation model underlying DLP is a model that supports distributed logic, and may be seen as a combination of the models underlying logic programming and parallel object-oriented languages. See slide dlp-objects-2.

The DLP support system provides, in addition to a Prolog-like evaluation mechanism, support for objects (having a state, and methods defined by clauses), processes (to realize the object's own activity as well as to evaluate method calls or goals for the object), and a communication mechanism (that allows for a backtrackable rendezvous).

As an example of an object in DLP, look at the travel agency defined in slide dlp-objects-3, which has a non-logical instance variable cities (containing a number of destinations), a constructor travel (which defines the object's own activity) and two methods, reachable and add.


  object travel { 
travel
var cities = [amsterdam, paris, london]. travel() :- accept( all ), travel(). reachable(X) :- member(X, cities). add(X) :- append( cities, [X], R), cities := R. }

Usage

   ?- O = new travel(), O!reachable(X), write(X).
  

slide: DLP -- objects (3)

The reachable method may be used to ask whether a particular destination exists or to ask for all possible destinations (which are actually obtained by backtracking). The add method may be used to add new destinations to the list of cities.

The travel constructor merely consists of a (tail-recursive) loop allowing to accept any request, one at a time. By specifying which requests may be accepted at a particular point in the lifetime of the object, the message interface of the object may be dynamically specified. In addition, an explicit accept statement is needed to guarantee mutual exclusion between method calls.