Name resolution at run time

The rules for name resolution at run time tell whether a given variable, constant, parameter, or function is visible to an expression. These rules concern scope, which is a definition of the code area from which a given memory area is accessible.

The order of priority for resolving references at run time is as follows:
  1. First in precedence are declarations that are local to the function where the expression resides. This category includes the local variable, constant, and function-parameter declarations.
  2. Second in precedence are declarations that are outside of a function but are inside the part where the expression resides. Each field is program global, which means that it is accessible to all functions in the part. This category includes the global variable, constant, program-parameter, and function declarations.
  3. Third are declarations that are outside a function but are inside a library that is accessible to the expression. Each public field is run-unit global, which means that it is accessible to all functions in the run unit. This category includes the variable, constant, and function declarations in the library. Those declarations are program global to other functions in the same library.
  4. Fourth are declarations that are in EGL system libraries.
A reference in an expression can include a series of identifiers, with a period (.) separating one from the next. Here is an expression in which each operand is fully qualified:
autoPkg.AutoLibrary.numberInFleet - autoPkg.CarLibrary.DebtRecord.carLimit

As appropriate, the identifiers can include a package name, a part name, a declaration name (for example, for a record), and a member name such as the name of a record field.

The package name and part name are especially useful for accessing values and functions in a library, as suggested in the example. However, you can code the use statement for the convenience of referring more directly to the declarations in a library. For details, see “Use statement.”

If a local declaration has the same name as the program-global declaration, only the local declaration is visible to the expression; but you can override that rule. For details, see “This keyword.”