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

Subsections

3.2 Core Behaviors

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".
DERIVABLE
Derivable objects respond to derive and deriveWith:, which means they can be readily extended.
CLONEABLE
Cloneable objects are derivables that can be cloned.
METHOD
A Cloneable object with attributes for supporting execution of blocks 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
print returns a printed representation of the object. printOn: places the result of printing onto a designated Stream. This should be overridden.
Delegation-testing
is: returns whether the first object has the second as one of its delegated objects, directly or indirectly.
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 address in memory. What's more important about hashing is that 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.
Conversion/coercion
The as: method has a default implementation on root objects. Essentially the purpose of the as: protocol is to provide default conversion methods between types of objects in Slate. Some primitive types, such as Number, override this. For now, if no converter is found or if the objects are not of the same type, the failure answer is Nil. Precisely, the behavior of a as: b is to produce an object based on a which is as much like b as possible.
Slot-enumeration
For each object, the Symbols naming its slot and delegate slots can be accessed and iterated over, using the accessors slotNames and delegateNames, which work with the symbol names of the slots, or the iterators slotsDo: and delegatesDo:, which iterate over the stored values themselves.

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
Next: 3.3 Traits Up: 3 The Slate World Previous: 3.1 Overall Organization   Contents
The Slate Project 2003-07-29