ONC+ Developer's Guide

Optional-Data

Optional-data is one kind of union that occurs so frequently that it is given a special syntax of its own for declaring it. It is declared as follows:

type-name *identifier;

This is equivalent to the following union:

union switch (bool opted) {
 	case TRUE:
 	type-name element;
 	case FALSE:
 	void;
} identifier;

It is also equivalent to the following variable-length array declaration, since the Boolean opted can be interpreted as the length of the array:

type-name identifier<1>;

Optional-data is useful for describing recursive data-structures, such as linked lists and trees.