In a programming language, a type is a description of a set of values and a set of allowed operations on those values. PL/I has many built-in data types. Each type can specify a number of elementary attributes. PL/I allows you to define your own types by using the built-in data types. This chapter discusses user-defined types (aliases, ordinals, structures, and unions), declarations of variables with these types, handles, and type functions.
For information about these built-in data types, see Data elements.
All types that are created by DEFINE statements follow the same scoping rules that apply to names in DECLARE statements. For example, an ORDINAL defined in a procedure is known in all child procedures of that procedure, but not in any of its sister or parent procedures. Therefore, if a procedure returns a type, that type must be defined in a parent procedure or at the package level.
A DEFINE statement for a type must precede any use of that type.
A type name in a DEFINE statement must not start with __ (2 underscores).
The type reference can consist of possibly a series
of identifiers separated by dots, for example,
For each variant of the DEFINE statement, there is a corresponding XDEFINE statement which has the same syntax (except for the initial keyword). If the name specified in the XDEFINE statement has already appeared in a previous (X)DEFINE statement for the same type, then the XDEFINE statement will be ignored. An XDEFINE statement must not specify a name that has already been defined as a different type (for example, an XDEFINE ALIAS statement must not specify a name that has already appeared in an XDEFINE ORDINAL statement).