Sequence Types
A sequence type specifies the type of items that may appear in a sequence, as well as an indication about the cardinality of the sequence.
Syntax
sequence_type ::= type_definition
[quantifier]
quantifier := "*" | "+" | "?"
Semantics
subtype relationship
A subtype relationship exists among sequence types as well. It is defined as follows:
- The empty sequence is a subtype of all sequence types whose quantifier is * or ?
- A sequence type SUB is a subtype of another sequence type SUP (supertype) if SUB's item type is a subtype of SUP's item type, and SUB's quantifier is a subquantifier of SUP's quantifier, where the subquantifier relationship is defined by the following matrix.
The following matrix illustrates the subquantifier relationship between the quantifiers. The column heading indicate the supertype(SUP) of the quantifier. The row heading indicate the subtype (SUB) of the quantifier.
For example, as per the above table, ? is a superquantifier of one and ?, but is not a superquantifier of + and *. Similarly, * is a superquantifier of all other quantifiers.
Sup Q1 | Sub Q2 | one | ? | + | * |
one | true | false | false | false |
? | true | true | false | false |
+ | true | false | true | false |
* | true | true | true | true |
Note:
In the following sections, when we say that an expression must have (sequence) type T, what we mean is that when the expression is evaluated, the result sequence must have type T or any subtype of T. Similarly, the usual subtype-substitution rules apply to input sequences: if an expression expects as input a sequence of type T, any subtype of T may actually be used as input.