Message delegation and self-reference
\dlpindex{delegation}
\dlpindex{self reference}
Extensive research has been invested in using Horn clause logic
for querying and updating a database.
Partly this research has been motivated by the flexibility
of Horn clause logic for defining virtual attributes,
the values of which are not given by actual data items
but must be computed from the information stored.
A somewhat radical extrapolation of these attempts
is represented by approaches using objects to store information
and to guide the retrieval. Such retrieval may partly take place by
evaluating clauses.
Cf. [HB88].
As an example of an object oriented approach, to (for instance)
modelling the hierarchical organization of a firm,
consider the following program fragment,
telling us that an employee has a manager, and that in his turn
a manager is an employee.
\lprog{firm}{
.ds firm.pl
}
For an employee to undertake any action he/she must request his/her
manager for approval.
This is implemented by asking the manager stored in the
non-logical variable of the employee to approve of that particular
action.
Since the manager is an employee, he himself may have to ask
for approval of his manager.
Chaining upwards in the hierarchy a manager must exist
that has no obligation to ask for approval.
This manager may be created with self as an argument for
the constructor,
which makes asking for approval a local affair, depending on what
the top manager himself considers reasonable and important.
The goal
:-
M = new(manager(self)),
E = new(employee(M)),
E ! request(domestic_trip, A).
provides
an example of creating a one-level hierarchy.