Indirect Provision

Indirect provision occurs when the library program exports an object that is, in turn, imported from another library. The system then attempts to link the client process to this second library, which can provide the exported object directly, indirectly, or dynamically. A chain of indirect or dynamic provisions must eventually end in a library that provides the object directly.

Exported Data

Indirect provision can be used only for exported procedures, not for exported data.

Indirect Provision and Server Library Objects

The following is an example of an ALGOL server library that provides procedure PROC1 indirectly, by importing PROC1 from another server library called OBJECT/PROVIDER:

LIBRARY OTHERLIB(LIBACCESS = BYTITLE, TITLE = “OBJECT/PROVIDER”);

PROCEDURE PROC1;
   LIBRARY OTHERLIB;

EXPORT PROC1;

FREEZE(PERMANENT);

Indirect Provision and Connection Library Objects

Server libraries can provide objects indirectly, but connection libraries cannot. That is, a connection library cannot import an object and then export the same object. Further, a connection library cannot use an object that is indirectly provided through a server library. For example, a connection library could not link to the library in the preceding example and invoke procedure PROC1.

It is possible for a server library to indirectly provide procedures that originate in a connection library. However, to do this, the server library must use procedure references or procedure reference arrays. Procedure references and procedure reference arrays are supported in NEWP and in all varieties of ALGOL.

The following ALGOL server library imports the procedure PROC1 from the connection library with the INTERFACENAME of CLTEST in the program OBJECT/CLTEST. This server library then indirectly exports PROC1 to any client programs that link to this server library:

LIBRARY CL1 (LIBACCESS = BYTITLE, TITLE = “OBJECT/CLTEST.”,
             INTERFACENAME = “CLTEST.”);

PROCEDURE PROC1;
   LIBRARY CL1;

PROCEDURE REFERENCE PREF;

RSLT:= LINKLIBRARY (CL1); 
PREF:= PROC1; 
EXPORT PREF AS “PROC1”; 
FREEZE (PERMANENT);

Note that this server library exports a procedure reference PREF instead of PROC1 itself. The use of the procedure reference is necessary because this server library imports PROC1 from a connection library. The use of procedure references is the only way to indirectly provide a connection library procedure.

Indirect Provision Compared with Indirect Usage

A program can obtain an effect similar to indirect provision by directly exporting a procedure that includes a statement that uses an imported object. For example, the following ALGOL example imports procedure PROC1 from library LIB1. This program then freezes as a server library, exporting procedure OTHERPROC, which includes an invocation of LIB1.

LIBRARY LIB1 (LIBACCESS=BYFUNCTION,FUNCTIONNAME=“LIBTEST.”,
              INTERFACENAME=“CONLIB.”);

PROCEDURE PROC1;
   LIBRARY LIB1;

PROCEDURE OTHERPROC;
   BEGIN
   PROC1;
   END;

EXPORT OTHERPROC;
FREEZE (TEMPORARY);

In this example, PROC1 could be imported from another server library or from a connection library. The usual restriction on indirect provision of connection library objects does not apply here, because OTHERPROC is not actually linked to PROC1.