The SEQUENCE type is very similar in syntax to SET type. The major difference is, that the order in which components appear in definition is significant.This also implies some more defferences, which will be mentioned one after another on this page. Sequence types are used commonly instead of set types if any natural order is needed, e.g. in protocols.
The type notation is as follows:
Protocol ::= SEQUENCE {
DA INTEGER (0..65535), -- destination adress
SA INTEGER (0..65535), -- source adress
TP ProtocolType,
BD OCTET STRING OPTIONAL -- body, data
}
ProtocolType ::= ENUMERATED {data | ack | req | command}
Then, value notation is as follows:
Prot1 Protocol ::= {DA 32158, SA 1584, TP ack}
Thus, following notation is not a valid one:
Prot2 Protocol ::= (SA 1943, DA 35421, TP data, BD '03fa4d5'H)
It is also possible to define a sequence type, within which distinctiness is implied by types used. That means, it is sometimes acceptable to omit identifiers. Our example Protocol is one of possible type definitions.
Subtyping possibilities are equal with the SET type considering the fact, that components must keep the order.