next up previous contents
Next: 3.10 Modules Up: 3 The Slate World Previous: 3.8 Files   Contents

Subsections

3.9 Types

In coordination with the reserved syntax for type-annotation in block headers, Slate's standard libraries include a collection of representations of primitive TYPES as well as quantifications over those types.

The library of types is laid out within the non-delegated namespace Types in the lobby.

Any
The type that any object satisfies: the universal type.
None
The type that no object satisfies: the empty type.
Range
A parametrized type over another type with a linear ordering, such as Integer. This type is bounded, it has a start and a finish (least and greatest possible member). In general, any Magnitude can be used as a base of a Range type.
Member
The type associated with membership in a specific set of objects.
Singleton
The type of a single object, as distinct from any other object.
Clone
The type of an object and its CLONE FAMILY, the set of objects that are direct copies of it.
Array
The Array type is parametrized by an element type and represents arrays of all length of that type.
Block
The Block type represents code closures of a given (optional) input and output signature.
Types may be combined in various ways, including union:, intersection:, and extended via derive and deriveWith: which preserve type constraints on the derivations.

Type Annotations

Local slot specifiers in a Method header as well as input slot specifiers may have types optionally declared within the header. Within a method declaration expression, the input slots may be redundantly specified in the header as well as in the dispatch expression. However, if this is done, the header's specifier needs to be specified as an input slot and if multiple input slot types are specified, they should be specified in order.

The syntax is similar to that for @-based dispatch notation: follow the slot name with the bang character ``!'' and then a type expression, which may be a primitive or derived type. For example,

[| :foo!Integer bar | bar: (foo raisedTo: 3).  
foo + bar] value: 4.3.
Type annotations don't use primitive expressions: the evaluator doesn't have a library of pre-built types at its disposal. Instead, Type annotation expressions are evaluated within the namespace named Types accessible from the lobby. For this reason, user-defined named types should be installed in some place accessible through the Types path.


next up previous contents
Next: 3.10 Modules Up: 3 The Slate World Previous: 3.8 Files   Contents
The Slate Project 2003-07-29