Primitives
Strings
categories
Objects, Classes and Slots
Objects and Entities
Classes

Objects, Classes and Slots

Objects and Entities

A program in CLAIRE is a collection of entities (everything in CLAIRE is an entity). Some entities are pre-defined, we call them primitive entities, and some others may be created when writing a program, we call them objects. The set (a class) of all entities is called any and the set (a class also) of all objects is called object.

[XL] In XL CLAIRE port are not imported entity but implemented an extensible class vs. primitive (see port).

Primitive entities consist of integers, floats, symbols, strings and functions. The most common operations on them are already built in, but you can add yours. You may also add your own entity classes using the import mechanism.

Objects can be seen as "records", with named fields (called slots) and unique identifiers. Two objects are distinct even if they represent the same record. The data record structure and the associated slot names are represented by a class. An object is uniquely an instance of a class, which describes the record structure (ordered list of slots). CLAIRE comes with a collection of structures (classes) as well as with a collection of objects (instances).

Definition : A class is a generator of objects, which are called its instances. Classes are organized into an inclusion hierarchy (a tree), so a class can also be seen as an extensible set of objects, which is the set of instances of the class itself and all its subclasses. A class has one unique father in the inclusion hierarchy (also called the inheritance hierarchy), called its superclass. It is a subclass of its superclass.

Each entity in CLAIRE belongs to a special class called its owner, which is the smallest class to which the entity belongs. The owner relationship is the extension to any of the traditional isa relationship between objects and classes, which implies that for any object x, x.isa = owner(x).

Thus the focus on entities in CLAIRE can be summarized as follows: everything is an entity, but not everything is an object. An entity is described by its owner class, like an object, but objects are "instantiated" from their classes and new instances can be made, while entities are (virtually) already there and their associated (primitive) classes don't need to be instantiated. A corollary is that the list of instances for a primitive class is never available.


categories Objects and Entitiesnormal dispatch operationCore method

!=(x:any, y:any) -> boolean

this is the negation of (x = y).


categories Objects and Entitiesnormal dispatch operationKernel method

=(x:any, y:any) -> boolean

(x = y) returns true if x is equal to y and nil otherwise. Equality is defined as identity for all entities except strings, lists and sets. For lists, sets and strings, equality is defined recursively as follows: x and y are equal if they are of same size n and if x[i] is equal to y[i] for all i in (1 .. n).


categories Objects and Entitiesnormal dispatch Core method

known?(self:any) -> boolean

The general method known? simply returns true whenever the object exists in the database (i.e. false is returned if x is unknown vs. unknown?).


categories Objects and Entitiesnormal dispatch Core method

not(self:any) -> boolean

not(self) returns false for all entity except false, nil, the empty set and the empty list.


categories Objects and Entitiesnormal dispatch Core method

owner(self:any) -> class

owner(self) returns the class from which the object is an instance. If x is an object, then owner(x) = isa(x) = the unique class c such that x % instances(c).
 owner(12-> integer
 owner("12"-> string
 owner(integer-> class
 owner(integer U string-> Union


categories Objects and Entitiesnormal dispatch Core method

unknown?(self:any) -> boolean

The general method unknown? simply returns true if the entity is unknown in the database (vs. known?).