ONC+ Developer's Guide

Optional-Data

The optional-data union 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 syntax is equivalent to the following union:

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

The optional-data syntax is also equivalent to the following variable-length array declaration, because 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.