WELCOME TO Quintus Prolog The Industry Standard |
|
Quintus Home > Quintus Objects | |
Prolog with ObjectsQuintus Objects provides an efficient way for Prolog programmers to define and use objects in their programs. In Quintus Objects, an object is a data structure that holds information and responds to commands, which are called messages. Each kind of object is a class. Every object is a member of exactly one class and is an instance of its class. Using Quintus Objects, programmers can create and send messages to objects in their Prolog programs. A slot is a part of an object that holds data. In Quintus Objects, programmers may specify the type of a slot. The allowed types include the following:
This allows programmers to specify a definite, C-style type, when appropriate. Or, programmers may choose to allow general Prolog terms in a slot, to take advantage of the flexibility of Prolog. When an object is created, each slot is given an initial value based on its type. Numerical slots are initialized to 0, etc. Programmers may specify a different initial value, as part of the class definition. In addition to specifying its type and its initial value, programmers may also declare a slot to be private, which limits access to the slot. A method defines how an object responds to a message.
In Quintus Objects, methods are defined by Prolog clauses.
Instances of a class are created and destroyed by that class's Quintus Objects provides direct access to an object's slots,
using its built-in One of the most powerful features of object-oriented
programming is inheritance. In Quintus Objects, if a new
class is defined as a child (that is, a special case) of
an existing class, it inherits the slots and methods of its parent
class. The child class may add its own slots and methods, and it
may redefine some of the slots and methods it inherits. Quintus
Objects supports multiple inheritance, where a class may
inherit from more than one parent class, and its Quintus Objects supports debugging with its |