Subject: Interface Block / Host Association Proposal J3/01-397 From: Kurt W. Hirchert (Meeting 159) 06 Dec 2001 ========== Background ========== In his tutorial on the current state of the enhanced modules TR, Van expressed dissatisfaction with the current host association rules concerning interface blocks. During the resulting discussion, I expressed other concerns about the IMPORT statement in the current draft. As a result we were charged with proposing something better. After a couple of brainstorming sessions at lunch, this is what we came up with. It contains preliminary specs and syntax. (I.e., fine details of the specs probably need more refining, and the things like the choice of syntax keywords and punctuation are still up for grabs.) ======== Strategy ======== 1. Eliminate the IMPORT statement: a. Remove it from R204. b. Remove R1209, C1209, and C1210. c. Remove the description of IMPORT following Note 12.4. d. Eliminate or modify Note 12.6 (the example of using IMPORT). 2. Add the CONTEXT statement: a. Add " or " to R1202. b. R1209a is CONTEXT R1209b is EXTERNAL or MODULE c. Description of CONTEXT can go where we took out the description of IMPORT (following Note 12.4). d. Fix the example in Note 12.6 by removing "IMPORT T" after the "SUBROUTINE MONITOR ..." statement and adding "CONTEXT MODULE" before that statement. (Changes to the description of the example are left as an exercise for the reader.) =============== Basic Semantics =============== The CONTEXT statement is used to declare what host association is used in the interpretation of the interface bodies that follow it (i.e., until the next CONTEXT statement or the end of the interface block). CONTEXT EXTERNAL is the default and indicates that the affected interface bodies access nothing through host association (i.e., they are like external procedures). This is legal in interface bodies everywhere, and may be applied to interface bodies for external procedures, dummy procedures, and abstract interfaces. CONTEXT MODULE indicates that the affected interface bodies use host association to access entities from the _module_ that ultimately contains it, _not_ the scoping unit which immediately contains the interface block. (In other words, the affected interface bodies are interpreted like module procedures.) It is legal only within a module (including its module procedures and their internal procedures). It may be applied to interface bodies for dummy procedures and abstract interfaces, but not to module procedures (since they already have explicit interfaces). ============================= IMPORT vs. CONTEXT Comparison ============================= 1. IMPORT requires a list of the specific entities to be accessed. CONTEXT MODULE provides everything in the module automatically. 2. Declarations in the immediate host of an interface block can change the meaning of a name accessed via IMPORT from its meaning in the class of module procedures being described. CONTEXT MODULE operates directly out of the module, so no such distortion can take place. 3. It is possible for a single CONTEXT MODULE statement to apply to multiple interface bodies. Each interface body would have required its own specification of an IMPORT list. 4. Because the IMPORT statement appears within the interface body, it may interfere with the ability to use techniques like INCLUDE files or cut and paste to use the identical text in an interface body as in the procedure being described. The CONTEXT statement appears outside the interface body and should should not have this effect. ================================================= Extending CONTEXT to the Enhanced Module Facility ================================================= CONTEXT MODULE is now also allowed in a submodule and accesses the module of which that submodule is logically a part. " or SUBMODULE []" is added to R1209b. CONTEXT SUBMODULE is similar to CONTEXT MODULE. If an affected interface body is for a dummy procedure or abstract interface, CONTEXT SUBMODULE access the submodule in which it appears, and CONTEXT SUBMODULE accesses the named submodule, subject to the requirement that this be a submodule of which the current submodule is logically a part. If an affected interface body is not for a dummy procedure or abstract interface, it is a declaration of the interface for a module procedure in a submodule of the module or submodule in which the interface block appears. Host association in the interface body is from that module or submodule. If is present, the actual module procedure must be in that submodule (or one of its submodules). - end -