9 August 2005 05-202r1 Subject: Edits to allow internal subprograms as actual arguments and procedure pointer targets From: Van Snyder References: 04-148, J3 05-009-013, WG5/N1626-J3-013 1. Detailed Specification Allow an internal subprogram to be an actual argument Allow the host of the internal subprogram to be recursive. Access by host association from the internal subprogram when it is invoked via a dummy procedure, to entities of its host is access to entities in the instance of its host when the internal subprogram was used as an actual argument. This is not necessarily the same instance of its host as when the internal subprogram is invoked. Allow an internal subprogram to be a procedure pointer target. When an internal procedure is invoked via a pointer the instance of the host accessed by host association is the instance when the procedure's name was a . This is not necessarily the instance when the internal subprogram is invoked via the pointer. A procedure pointer associated with an internal subprogram becomes undefined when the instance of the procedure defined by its host subprogram that was in existence when the pointer association was established ceases to exist. 2. Syntax There is no new syntax. 3. Edits [144:5] Within the penultimate constraint (C727) of 7.4.2 Pointer assignment, after "external" insert ", internal", making the constraint read: "C727 (R742) A shall be the name of an external, internal, module or dummy procedure, a specific intrinsic function listed in 13.6 and not marked with a bullet (O), or a procedure pointer." [144:36-38] After the first paragraph of 7.4.2.2 Procedure pointer assignment insert a new second "If is the name of an internal procedure the <> of becomes the innermost currently executing instance of the host procedure. Otherwise if has a host instance the host instance of becomes that instance. Otherwise has no host instance." [267:15-17] Replace the fifth constraint (C1229) after (R1222) by the text of C727 in the edit for 144:5, making it C1229 and applying to R1221: "C1229 (R1221) A shall be the name of an external, internal, module or dummy procedure, a specific intrinsic function listed in 13.6 and not marked with a bullet (O), or a procedure pointer." [267:17+1-7] Delete Note 12.16 -- the one that begins "This standard does not allow..." [271:12+] Insert a new first paragraph in 12.4.1.3 Actual arguments associated with dummy procedure entities. "If the actual argument is the name of an internal subprogram, the host instance of the dummy argument is the innermost currently executing instance of the host of that internal subprogram. If the actual argument has a host instance the host instance of the dummy argument is that instance. Otherwise the dummy argument has no host instance." [271:16] Within the second paragraph of 12.4.1.3 Actual arguments associated with dummy procedure entities", after "external" insert ", internal". [282:35] Within the second sentence within the second paragraph of 12.5.2.3 Instances of a subprogram replace "directly" with "by name". [282:37] At the end of the second paragraph of 12.5.2.3 Instances of a subprogram insert a new sentence "If an internal procedure is invoked via a dummy procedure or procedure pointer, the internal procedure has access to the entities of the host instance of that dummy procedure or procedure pointer." [415:7+] After item (4) in the numbered list in 16.4.2.1.3 Events that cause the pointer association status of pointers to become undefined -- the item that begins "Execution of a RETURN..." -- insert a new level-1 item: (4a) Execution of the host instance of a procedure pointer is completed by execution of a RETURN or END statement. [418:18] Within the second paragraph of 16.4.5 Establishing associations, before the third sentence -- the one that begins "If the host scoping unit...: -- insert a new sentence: "If an internal procedure is invoked via a dummy procedure or procedure pointer, the pre-existing entity that participates in the association is the one from the host instance." Then replace "If" by "Otherwise if".