SEQUENCE OF Type Elements in Other Constructed Types

Frequently, a SEQUENCE OF construct is used to define an array of some common type in an element in some other constructed type (for example, a SEQUENCE). An example of this is as follows:

   SomePDU ::= SEQUENCE {
      addresses SEQUENCE OF AliasAddress,
      ...
   }

Normally, this would result in the addresses element being pulled out and used to create a temporary type with a name equal to “SomePDU-addresses” as follows:

   SomePDU-addresses ::= SEQUENCE OF AliasAddress

   SomePDU ::= SEQUENCE {
      addresses SomePDU-addresses,
      ...
   }

However, when the SEQUENCE OF element references a simple defined type as above with no additional tagging or constraint information, an optimization is done to cut down on the size of the generated code. This optimization is to generate a common name for the new temporary type that can be used for other similar references. The form of this common name is as follows:

   _SeqOf<elementProdName>

So instead of this:

   SomePDU-addresses ::= SEQUENCE OF AliasAddress

The following equivalent type would be generated:

   _SeqOfAliasAddress ::= SEQUENCE OF AliasAddress

The advantage is that the new type can now be easily reused if “SEQUENCE OF AliasAddress” is used in any other element declarations. Note the (illegal) use of an underscore in the first position. This is to ensure that no name collisions occur with other ASN.1 productions defined within the specification.

An example of the savings of this optimization can be found in H.225. The above element reference is repeated 25 different times in different places. The result is the generation of one new temporary type that is referenced in 25 different places. Without this optimization, 25 unique types with the same definition would have been generated.