next up previous

9.6 MANIPULATING INSTANCES

Objects are manipulated by sending them messages. This is achieved by using the send function, which takes as arguments the destination object for the message, the message itself and any arguments which are to be passed to handlers.

Syntax

(send <object-expression>
    <message-name-expression> <expression>*)

Section 2.4.2 explains object references. The return value of send is the result of the message as explained in section 9.5.5.

The slots of an object may be read or set directly only within the body of a message-handler that is executing on behalf of a message that was sent to that object. This is how COOL implements the notion of encapsulation (see Section 2.6.2). Any action performed on an object by an external source, such as a rule or function, must be done with messages. There are two major exceptions: 1) objects which are not instances of user-defined classes (floating-point and integer numbers, symbols, strings, multifield values, fact-addresses and external-addresses) can be manipulated in the standard non-OOP manner of previous versions of CLIPS as well and 2) creation and initialization of an instance of a user-defined class are performed via the function make-instance.

9.6.1 Creating Instances

9.6.2 Reinitializing Existing Instances

9.6.3 Reading Slots

9.6.4 Setting Slots

9.6.5 Deleting Instances

9.6.7 Modifying Instances

9.6.8 Duplicating Instances



next up previous