Object class

From m204wiki
Revision as of 03:35, 16 July 2012 by Alex (talk | contribs)
Jump to navigation Jump to search

The Object class is an implicit base class for all classes. However, until Sirius Mods 8.1, there was no way to reference the Object base class via object variables of any of its extension classes (that is all classes other than the Object class) and there was no way to assign an variable of one class to a variable of its base Object class. This is all possible in Sirius Mods 8.1.

In Sirius Mods 8.1, it is possible to invoke an Object class method against any object. For example:

b %foo is object stringlist %foo = new printText {~=%foo:className} end

would display:

%foo:className=System:Stringlist

And

b class pair public variable x is float variable y is float end public end class %pair is object pair %pair = new printText {~=%pair:className} end

would display:

%pair:className=Pair

These examples illustrate that not only is the Object class an implicit base class of every class (in fact it is not permissible to explicitly declare the Object class as a base class) but that every extension class of the Object class inherits the Object class member names so that the Object class does not have to be specified on an Object class member reference. However, as with other extension classes, all classes can "hide" a base class member by containing a member with the same name. For example, if we add the member ClassName to class Pair in the above example, %pair:className would refer to the Pair class className. However, in such a case, it would be possible to reference the Object class className by preceding it with (object) as in:

b class pair public variable x is float variable y is float variable classname is string len 32 end public end class %pair is object pair %pair = new %pair:className = 'This name makes no sense' printText {~=%pair:className} printText {~=%pair:(object)className} end

which displays:

%pair:className=This name makes no sense %pair:(object)className=Pair

Generic Print, Audit, and Trace Methods

Sirius Mods 8.0 introduced generic Print, Audit, and Trace methods that could be applied to all User Language objects. So, to a large degree, these were essentially base Object class methods that could be invoked via User Language object variables. However, they did not behave like true Object class methods because they were not available to system classes and because one could not explicitly specify the methods class via (object) before the Print, Audit, or Trace method name. This meant that if a class had one or more of these methods already defined, there was no way to get at the Object class (generic) methods of the same name. These issues are all corrected in Sirius Mods 8.1 so that the Print, Audit, and Tracemethods are full-fledged members of the Object class.

List of Object methods

The "List of Object methods" shows all the class methods, with a brief description of each.