Dynamic Provision

Dynamic provision is similar to indirect provision in that it enables a library to export an object that, in turn, was imported from another library. However, dynamic provision allows the primary library to import objects with the same name from multiple secondary libraries. Whenever a client process attempts to import an object with that name, the primary library can dynamically select the version of the object to provide to the client process.

For an example of a library using dynamic provision, refer to ALGOL Library: OBJECT/SAMPLE/DYNAMICLIB later in this section.

Restrictions

  • The dynamic provision feature is supported only in ALGOL.

  • Server libraries can provide objects dynamically, but connection libraries cannot.

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

BY CALLING Clause for Exporting Procedures

Procedures that are exported dynamically include a BY CALLING clause, as in the following example:

PROCEDURE READFILE;
    BY CALLING SELECTION;

Selection Procedure

The BY CALLING clause specifies the name of a selection procedure, which you must declare elsewhere in the library program. Whenever a client process first links to a library, the system checks to see if any objects imported by that client process are provided by the library with a BY CALLING clause. If so, the system invokes the selection procedure. The selection procedure must accept the following two parameters from the system:

  • A parameter of type EBCDIC string, which the system uses to pass in the value of the LIBPARAMETER library attribute as specified by the client process. This parameter enables the client process to convey information to the library that might help the library decide from which secondary library to import the object.

  • A parameter of type procedure, which the system uses to pass in an MCP procedure. This procedure itself has a parameter, which is a task variable. The selection procedure must invoke the MCP procedure before exiting, and must pass to it the task variable of the secondary library that has been selected. Otherwise, the linking process is discontinued.

Secondary Library

The secondary library that is selected can provide the requested object directly, indirectly, or dynamically. A chain of indirect or dynamic provisions must eventually end in a library that provides the object directly.

Note that the secondary library must be a server library, not a connection library.

Selection Occurs during Linkage

The selection procedure is invoked only at library linkage time. All links to exported objects in the library are resolved during linkage. To cause the selection of a different secondary library after linkage, the client process must first delink from the dynamic library. The client process can then modify the LIBPARAMETER library attribute to request a different secondary library, and relink to the dynamic library.