next up previous contents index
Next: 3.3 Introspection Up: 3 The Slate World Previous: 3.1 Overall Organization   Contents   Index

Subsections

3.2 Core Behaviors

Figure 1: Core Object Inheritance

\includegraphics{/Applications/Office/0_Users_water_Slate_main_doc_core-web.eps}

Slate defines several subtle variations on the core behavior of objects:

Root
The "root" object, upon which all the very basic methods of slot manipulation are defined.
Oddball
The branch of Root representing non-cloneable objects. These include built-in 'constants' such as the Booleans, as well as literals (value-objects) such as Characters and Symbols. Note that Oddball itself defines a clone method, but that method will only work once, in that you can clone Oddball but not objects made by cloning Oddball.
Nil
Nil is an Oddball representing "no-object".
NoRole
NoRole is an Oddball representing a non-dispatching participant in a method definition. Methods cannot be defined directly on NoRole.
Derivable
Derivable objects respond to derive, which means they can be readily used for extension.
Cloneable
A Derivable that can be cloned.
Method
A Cloneable object with attributes for supporting execution of blocks (with closure semantics, notably) and holding compiled code and its attributes.

3.2.1 Default Object Features

Identity
== returns whether the two arguments are identical, i.e. the same object, and ~== is its negation. Value-equality (= and its negation ~=) defaults to this.
Printing
printString returns a printed (string) representation of the object. printOn: places the result of printing onto a designated Stream (print will invoke printOn: on the Console). This should be overridden for clarity.
Delegation-testing
isReally: returns whether the first object has the second (or its traits object if it is not a Trait) as one of its delegated objects, directly or indirectly.
Kind-testing
is: returns whether the first object has the same kind as the second object, or some derived kind from the second object's kind. By default, is: is isReally:; overrides can allow the user to adapt or abuse this notion where delegation isn't appropriate but kind-similarity still should hold. isSameAs: answers whether the arguments have the same traits object.
Hashing
A quick way to sort by object value that makes searching collections faster is the hash method, which by default hashes on the object's identity (available separately as identityHash), essentially by its birth address in memory. More importantly, this is how value-equality is established for collections; if an object type overrides =, it must also override the hash method's algorithm so that a = b $\Rightarrow$ a hash = b hash.
Cloning
The clone method is fundamental for Slate objects. It creates and returns a new object identical in slot names and values to the argument object, but with a new unique identity. As such, it has a very specific meaning and should only be used that way.
Copying
The copy method makes a value-equal (=) object from the argument and returns the new object. This should be overridden as necessary where = is overridden. The default case is to clone the original object.
Conversion/coercion
the as: protocol provides default conversion methods between types of objects in Slate. Some primitive types, such as Number, override this. The as: method has a default implementation on root objects: if no converter is found or if the objects are not of the same type, the failure will raise a condition. Precisely, the behavior of a as: b is to produce an object based on a which is as much like b as possible.

3.2.2 Oddballs

There are various Oddballs in the system, and they are non-cloneable in general. However, Oddball itself may be cloned, for extension purposes.


next up previous contents index
Next: 3.3 Introspection Up: 3 The Slate World Previous: 3.1 Overall Organization   Contents   Index
Brian Rice 2005-11-21