Static Tables

Tables provide simple look-up tables that can be used by functions in pattern bodies. They have no active behaviour. Tables must be declared in module scope, not inside pattern declarations. Declarations have the following form:

table name version
  key1 -> value1;
  key2 -> value2;
  ...
end table;

Keys are literal values or expressions involving only literals; values are comma-separated sequences of literal values, or expressions involving only literals.

Tables can have a default value, specified with a key of default:

table example_table 1.0
  "one" -> "two";
  "three" -> "four";
  default -> "five";
end table;

Tables are accessed in pattern bodies using square brackets:

table_key := "one";
value := example_table[table_key];

For details of dynamic table use from TPL 1.2 onwards, see Table functions

Was this page helpful? Yes No Submitting... Thank you

Comments