Next: 3.4 Control-flow
Up: 3 The Slate World
Previous: 3.2 Core Behaviors
  Contents
Slate objects, from the root objects down, all respond to the message
traits, which is conceptually shared behavior but is not
as binding as a class is. It returns an object which is, by convention,
the location to place shared behavior. Most Slate method definitions
are defined upon some object's Traits object. This is significant
because cloning an object with a traits delegation slot will result
in a new object with the same object delegated-to, so all methods
defined on that traits object apply to the new clone.
Traits objects also have their own traits object, which is Traits traits.
This has the important methods defined on it for deriving new prototypes
with new traits objects:
- myObject derive
- will return a new clone of the object
with a traits object which is cloned from the original's traits object,
and an immutable delegation slot set between the traits objects.
- myObject deriveWith: mixinsArray
- will perform the same
operation, adding more immutable delegation links to the traits of
the array's objects, in the given order, which achieves a structured,
shared behavior of static multiple delegation. Note that the delegation
link addition order makes the right-most delegation target override
the former ones in that order. One interesting property of this method
is that the elements of mixinsArray do not have to be Derivable.
- obj addPrototype: name derivedFrom: parentsArray
- will
perform the effects of either derive or deriveWith:
using all the elements of the Sequence in the same order
as deriveWith:. It also assigns the name to the traits object's
name attribute as well as using the name for the attribute between
the surrounding object and the new prototype.
As with any method in Slate, these may be overridden to provide additional
automation and safety in line with their semantics.
Next: 3.4 Control-flow
Up: 3 The Slate World
Previous: 3.2 Core Behaviors
  Contents
The Slate Project
2003-12-05