Name

DefinedObject -- object with defined type and implementation


Synopsis

//
// DefinedObject -- object with defined type and implementation
//
@deftype DefinedObject
-		getType;
-		getClass;
- (BOOL)	respondsTo: (SEL)aSel;

-		describe: anOutputStream;
-		createIDString: aZone;
@end

Description

DefinedObject is the top-level supertype for all objects that follow the object programming conventions of the defobj library. The messages defined by this type are the only messages which should be assumed to be automatically available on objects that follow these conventions. In particular, use of messages defined by the Object superclass of the GNU Objective C runtime should not generally be assumed because future implementations of some objects might not give continued access to them.

The DefinedObject type defines a minimum of standard messages, and leaves to other types the definition of message that might or might not apply in any general way to particular objects.


Inherited behavior

The DefinedObject type inherits no behavior from any other type. It is the top of the interface type hierarchy for objects that follow the defobj programming conventions. All objects that follow these conventions should inherit from DefinedObject, either directly or indirectly through other types.


Defined behavior

-		getType;
-		getClass;
A strict separation can be maintained between messages that make up the interface of an object vs. the internal methods and structures that implement the object. The interface, if defined independently from implementation, is summarized by an object called a type, and the implementation is defined by the class that holds pointers to methods and establishes locations of instance variables. The defobj library represents both types and classes by runtime-accessible objects containing other objects that represent their various components. All these objects are defined by program metaobjects described elsewhere, but DefinedObject links every object to a class object and optionally to a type.

The getType message returns the type object (an instance of Type) that describes the complete set of messages available on an object. It returns nil if access to a type object has not been implemented for the object. The getClass message returns the class object (an instance of type DefinedClass) that implements the object. Every object always has a class.

- (BOOL)	respondsTo: (SEL)aSel;
The respondsTo: message returns true if the object implements the message identified by the selector argument. To implement a message means only that some method will receive control if the message is sent to the object. (The method could still raise an error.) The respondsTo: message is implemented by direct lookup in a method dispatch table, so is just as fast as a normal message send. It provides a quick way to test whether the type of an object includes a particular message.

-		describe: anOutputStream;
-		createIDString: aZone;
The describe: message prints a brief description of the object for debug purposes to the OutputStream object passed as its argument. Particular object types may generate object description strings with additional information beyond the built-in default, which is just to print the hex value of the object id pointer along with the name of its class. A String object consisting of this default description, called an ID string, is returned by the createIDString message.


Roger Burkhart <rmb@santafe.edu>
Last modified: