Frage

In ASN.1, you can declare a Value Reference like:

<identifier> <Type Reference> ::= <Value Notation>

For example:

cost INTEGER ::= 123

The Type Reference component can either be a built-in type, or a user-defined type. The question I have is, when referring to a user-defined type, does ASN.1 require that the type must have already been defined? (Suppose it is not defined until later). For example, would the following be valid ASN.1 syntax:

cost MyIntType ::= 50
MyIntType ::= INTEGER (0..100)

Note that MyIntType is referenced in a value assignment before it is declared in the type assignment.

Is that valid?

War es hilfreich?

Lösung

This is perfectly valid. It is not necessary to have the definition before the usage.

Note that sometimes you cannot avoid this situation for example if there are circular dependencies between types:

A ::= some definition involving B
B ::= some definition involving A

Andere Tipps

As @Henry explains, ASN.1 permits forward referencing; that is referencing before usage in the type definitions.

Also very useful (actually necessary) when defining mutually recursive data types.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top