Dynamic types and dynamic access

When EGL can only verify access to the contents of a variable at run time, that variable is a dynamic type. In practice, you are performing dynamic access when you refer to any of the following fields:
In this last case, the name of a field appears in brackets after the name of the record, as in the following example:
myCustomer["customerName"]

You can also use this bracket syntax with an ANY type variable or a Dictionary.

Access to expressions that use dot syntax (such as myRecord.myField) can also be dynamic. The following rule dictates how EGL behaves: If the leftmost part of a field access expression (a series of names separated by dots) is a dynamic type, or another expression whose type is ANY, then EGL uses dynamic access on any fields that follow. In practice this means that the expression must begin with the name of a Dictionary, a non-fixed record, or an ANY type variable for EGL to use dynamic access on fields that follow the expression.

Dynamic access is allowed wherever an ANY type variable is allowed; and wherever there is dynamic access, the type is ANY.

Statements that need the data type of the operands to generate the correct code (such as I/O statements) cannot use dynamic access expressions as operands.

Example

The following example shows various methods of dynamic access:
// Define a Dictionary named point
point Dictionary{x=1, y=1};

// Access value at key "x" of point
anInt = point["x"];

// Access point using normal data access syntax
anInt = point.x ;

// Access X using variable with value "x"
str String = "x";
anInt = point[ str ];

Feedback