Name scope of external data

In programming languages, the name scope is defined as the portion of an application within which a particular declaration applies or is known.

The name scope of external data under COBOL is the enclave. Under PL/I, it is the load module. Figure 1 and Figure 2 illustrate these differences.

Due to the difference in name scope for COBOL and PL/I, PL/I external data and COBOL EXTERNAL data (both reentrant and non-reentrant) do not map to each other, regardless of whether you attempt to share the data within the same load module or across different load modules. External variables with the same name are considered separate between COBOL and PL/I.

If your application relies on the separation of external data, however, do not give the data the same name in both languages within a single application. By giving the data in each load module a different name, you can change the language mix in the application later, and your application will still behave as you expect it to.

Figure 1. Name scope of external variables for COBOL dynamic call
name scope of external variables for dynamic call

In Figure 1, COBOL Programs 1, 2, and 3 comprise a COBOL run unit (a Language Environment enclave). EXTERNAL data declared in COBOL Program 1 maps to that declared in COBOL Program 2 in the same load module. When a dynamic call to COBOL Program 3 in another load module is made, the EXTERNAL data still maps, because the name scope of EXTERNAL data in COBOL is the enclave.

Figure 2. Name scope of external variables for PL/I fetch
The name scope of external variables for fetch

The name scope of external data in PL/I is the load module. In Figure 2, external data declared in PL/I Procedure 1 maps to that declared in PL/I Procedure 2 in the same load module. The fetched PL/I Procedure 3 in another load module cannot have any external data in it.