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

quantifier
The quantifier is one of the following:
  • * indicates a sequence of zero or more items.
  • + indicates a sequence of one or more items.
  • ? indicates a sequence of zero or one items.
  • The absence of a quantifier indicates a sequence of exactly one item.

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.
Sup Q1 | Sub Q2 one ? + *
one true false false false
? true true false false
+ true false true false
* true true true true
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.

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.