[Next] [Previous] [Up] [Top] [Contents] [Index]

4.3 Matching Against Type Patterns

4.3.1 Method Formal Type Patterns

In general, formal argument type patterns are of the form

'T <= type[param1, ..., paramN]
where N may be zero. If the 'T <= prefix is omitted, a fresh type variable is supplied to represent the type of the argument. Every formal parameter can thus be considered to have an associated implicit type variable bound to the dynamic type of the corresponding actual. If the <= type[...] upper bound is omitted, it defaults to any.

The type variable for the formal is bound to the dynamic type of the actual, not the static type of the actual. Since during typechecking of the caller, only the static type of the actual is known, this situation can be modeled by treating the type of an actual as some fresh type variable that is known only to be a subtype of the static type computed for the argument. Normally, this distinction between the static and dynamic type is not important, but it can be in some situations. In particular, if the corresponding type variable is used an as upper bound of some other type variable, as in section 4.1.5, there can be a great difference between the static and dynamic type. This point is discussed more in section 4.3.4.


The Cecil Language: Specification and Rationale, Version 2.1 - 25 MARCH 1997
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker