Next: , Previous: Tables, Up: Tables



3.12.1 Declaring Tables

You declare tables using the following syntax:

table [ type^+ ] of type
where type^+ is one or more types, separated by commas.

The indices can be of the following scalar types: numeric, temporal, enumerations, string, port, addr, or net. The yield can be of any type. So, for example:

         global a: table[count] of string;

declares a to be a table indexed by a count value and yielding a string value, similar to a regular array in a language like C. The yield type can also be more complex:

         global a: table[count] of table[addr, port] of conn_id;

declares a to be a table indexed by count and yielding another table, which itself is indexed by an addr and a port to yield a conn_id record.

This second example illustrates a multi-dimensional table, one indexed not by a single value but by a tuple of values.