Scope of Definitions

Depending on where a definition occurs, it will have different scope. Scope refers to the range of source lines where a name is known. There are two types of scope: global and local, as shown in Figure 50.

Figure 50. Scope of Definitions
This figure shows the two types of scope: global and local

In general, all items that are defined in the main source section are global, and therefore, known throughout the module. Global definitions are definitions that can be used by both the cycle-main procedure and any subprocedures within the module. They can also be exported.

Items in a subprocedure, on the other hand, are local. Local definitions are definitions that are known only inside that subprocedure. If an item is defined with the same name as a global item, then any references to that name inside the subprocedure will use the local definition.

However, note the following exceptions:

Sometimes you may have a mix of global and local definitions. For example, KLISTs and PLISTs can be global or local. The fields associated with global KLISTs and PLISTs contain only global fields. The fields associated with local KLISTs and PLISTs can contain both global and local fields. For more information on the behavior of KLISTs and KFLDs inside subprocedures, see Scope of Definitions.



[ Top of Page | Previous Page | Next Page | Contents | Index ]