Anonymous types

Anonymous types are created from DEFINE instructions.

Unlike user-defined types which are created with the TYPE instruction and are identified by a name, anonymous types are created automatically when defining variables with a complete type specification.

For example:
DEFINE name VARCHAR(50)
DEFINE cust_rec RECORD
           cust_id INTEGER,
           cust_name VARCHAR(50)
       END RECORD
DEFINE cust_list DYNAMIC ARRAY OF RECORD LIKE customer.*
The above code will define 3 anonymous types for the module:
  1. A type for VARCHAR(50).
  2. A structured type for the RECORD definition, including cust_id and cust_name fields.
  3. An array type using a structured type for elements.

When defining several variables with the same type specification, the compiler will only create one anonymous type, that will be reused for each variable definition.

Anonymous types are for example used when doing variable introspection with the reflection API, when returning a type from the reflect.Value.getType() method of a value object created from a variable.