Scope of Definitions
Any items defined within a subprocedure are local to the subprocedure. If a local item is defined with the same name as a global data item, then any references to that name inside the subprocedure use the local definition.
However, keep in mind the following:
- Subroutine names and tag names are known only to the procedure in which they are defined, even those defined in the cycle-main procedure.
- All fields specified on input and output specifications are global. When a subprocedure uses input or output specifications (for example, while processing a read operation), the global name is used even if there is a local variable of the same name.
When using a global KLIST or PLIST in a subprocedure some of the fields may have the same names as local fields. If this occurs, the global field is used. This may cause problems when setting up a KLIST or PLIST prior to using it.
For example, consider the following source.
For more information on scope, see Scope of Definitions.