Routing Parameters Between Procedures
In conventional programming systems, the results of procedures are used in a variety of ways, depending upon the context of the calls made upon them. A result may, for example:
- Provide the basis for a branch decision within the calling program.
- Become an argument to a subsequent procedure call.
- Be ignored and thus effectively discarded.
At run-time, the knowledge of a result's intended use usually lies solely within the calling program, which examines the results, passes it to a second procedure, or ignores it as it chooses.
In a distributed system, the transportation of results from callee to caller, carried out by means of one of more inter-process messages, can be an expensive operation, especially when the results are large. Data movement can be reduced in Cases 2 and 3 above by extending the Model to permit the intended disposition of each procedure result to be made known in advance to the callee's environment. In Case 2, provided both callees reside within the same process, the result can be held at its source and later locally supplied to the next procedure. In Case 3, the result can be discarded at its source (perhaps not even computed), rather than sent and discarded at its destination.
5.1 Specifying Parameters Indirectly
Variables offer potential for the eliminating the inefficiencies involved in Case 2 above by providing a place within the callees' process where results generated by one procedure can be held until required by another. The Protocol can be extended to permit variables to be used in this way by allowing the caller of any procedure to include optional "argument- and result-list mask" like the following as additional parameters of the CALL message:
parameter list mask
[LIST variable, ...)]
[CHARSTR]
A parameter list mask would permit each parameter to be transmitted either directly, via the parameter list, or indirectly via a VARIABLE within the callee's process. Thus each element of the mask specifies how the callee's environment is to obtain or dispose of the corresponding parameter. To supply the result of one procedure as an argument to another, the caller need only then appropriately set corresponding elements of the result and argument list masks in the first and second calls, respectively. The result list mask should be ignored if the procedure fails, and the error number and diagnostic message returned directly to the caller.
5.2 Providing Scratch Variables for Parameter Routing
Although each applications program could provide variables for use as described above, a more economical approach is to extend the Model to permit special "scratch variables," maintained by the environment without assistance from its applications program, to be created and deleted as necessary at run-time. Adding to the Protocol the following pair of system procedures enables the local environment to create and delete such variables in a remote process:
CRTVARIABLE (variable, value)
CHARSTR any
DELVARIABLE (variable)
CHARSTR
These procedures create and delete the specified VARIABLE, respectively. CRTVARIABLE also assigns an initial VALUE to the newly-created variable.
These new procedures enable the environment to make available to its applications program, primitives that have calling sequences similar to those of the corresponding system procedures but which accept the process handle of the target process as an additional argument. Their implementation required only that the environment identify the remote process from its internal tables and invoke CRTVARIABLE or DELVARIABLE in that process.
5.3 Discarding Results
The inefficiencies that result in Case 3 above are conveniently eliminated by allowing the caller to identify via the result list mask (for example, via a zero-length CHARSTR) that a result will be ignored and therefore need not be returned to the caller.