next up previous contents
Next: Encapsulation Example Up: Modules Previous: Modules Interface Declaration Example

 

Modules - Procedure Declaration

 

Placing interfaces in modules for visibility purposes has the following problems,

In the previous example, if sub1 is to call sub2 then an explicit interface for the latter must be visible to the former. Inserting the statement USE my_interfaces into sub1 would suffice, however, this causes a problem as sub1 will have its own interface contained within its body which is illegal due to there being duplicate declarations. A USE ONLY clause (see Section 16.5) could be used to skirt around this problem but in the general case this solution is too messy.

If we encapsulate the procedures into the module then the need for INTERFACE blocks is removed. The fact that the procedures are defined in the module means that their interfaces (and hence declarations) can be seen by all procedures at the same level in that module and any program unit that uses the module. These procedures are now called module procedures, and this approach should be adopted whenever possible.

Return to corresponding overview page gif




next up previous contents
Next: Encapsulation Example Up: Modules Previous: Modules Interface Declaration Example

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.