next up previous contents
Next: Type Inference Up: Types Previous: Operations   Contents

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] applyWith: 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.



Brian Rice 2004-08-24