J3/09-176r1 To: J3 From: Van Snyder Subject: "transfer of control" is used improperly, 2.3.5 is incomplete Date: 2009 May 6 References: 09-007r1, 09-109, 08-206 1. What this paper does This paper o Defines the normal execution sequence to be proceeding from one executable construct to the next in the order they appear in a scoping unit, as 2.3.5 currently does. o Specifies that DO constructs that are not DO CONCURRENT constructs, IF constructs, and SELECT constructs have implicit internal branching, as 2.3.5 currently but incorrectly does for all constructs. o Defines the effect on execution sequence of FORALL and WHERE, which 2.3.5 does not do, and of DO CONCURRENT constructs, which is currently done incorrectly by lumping them with other constructs. o Defines the effect on execution sequence of procedure references, but not by using the undefined term "transfer of control." o Defines the effect on execution sequence of completing a procedure, which is not currently done but could reasonably be construed to be a "transfer of control," since that term is not defined and the execution sequence does not continue at the next executable construct. o Defines branching as alteration of the normal sequence of execution instead of using the undefined term "transfer of control." o Defines GO TO, arithmetic IF, ande alternate RETURN to be branches, instead of using the undefined term "transfer of control". ERR=, EOR= and END= are already correctly defined to be branches. o Specifies that branching into a block is prohibited instead of using the undefined term "transfer of control." Thus it explicitly does not apply to normal completion of a procedure. Proper lexical nesting, and the constraints on ENTRY, prevent "transfer of control" into the interior of a block by other means. 2. Why this paper 2.3.5 [33:1ff] is poorly structured. It ought to specify the normal execution sequence first, then the exceptions. Rather, it specifies one exception, then the normal sequence, then some more exceptions. The term "transfer of control" is not defined. 8.2.1p1 [188:3-4] specifies that it is the result of a branch. 8.2.1p1 [188:5] further says that procedure references and control structures also cause transfer of control, but the term is used in several places where this is clearly not desired, resulting in contradictions. 2.3.5 doesn't explain how execution proceeds when execution of a procedure completes. RETURN [12.6.2.7p1 313:27-31] just says it completes execution of a procedure (in the case an alternative return is not taken, which is explained by reference to branching). END is defined in terms of RETURN. It clearly meets the requirements for the imprecise definition of "transfer of control," and is therefore prohibited by 8.1.2.1. if the procedure was referenced within a block. FORALL and WHERE constructs are not mentioned in 2.3.5. We can't just add them to the second list item because they do not have "implicit internal branching". DO CONCURRENT is not properly treated in 2.3.5; it isn't really like other DO constructs in that it does not have "implicit internal branching". The first version of this paper, 08-206, was rejected at meeting 185 with the comment "new feature," but it definitely did not describe a new feature; it was a correction of an incomplete and erroneous description. A successor, 09-109, was submitted to meeting 187, but there wasn't time to process it. This paper updates the references from 09-109 to refer to 09-007r1. 3. Edits w.r.t. 09-007r1. [5:1+ 1.3.17+] --------------------------------------------------------- Editor: Insert a subclause: "1.3.17a branch change the normal execution sequence (8.2)" Index this occurrence of "branch". [13:33+ 1.3.93+] ------------------------------------------------------- Editor: Insert a subclause: "1.3.82a Normal execution sequence the order in which executable constructs appear (2.3.5)" [33:8-11 2.3.5p2] ------------------------------------------------------ Editor: Delete "When ... point." Its essence will reappear later. [33:11 2.3.5p2] -------------------------------------------------------- Editor: Replace "effect of execution" by "effect of the <>". {Define the term "normal execution sequence", which will be used in 8.2.1.} [33:12 2.3.5p2] -------------------------------------------------------- Editor: Insert "within a scoping unit" before "are executed in the order" and delete "in the main program or subprogram" (so that the execution sequence doesn't flow across CONTAINS). [33:14-15 2.3.5p2] ----------------------------------------------------- Editor: Replace the first list item by: "o Branching (8.2, 9.11.3, 9.11.4, 12.6.2.7) changes the execution sequence by explicitly specifying a new starting place, within the same scoping unit as the branch, for the execution sequence. "o Invocation of a procedure is described in subclauses 12.5.3 and 12.5.4. When a procedure is invoked, the specification expressions within the of the invoked procedure, if any, are evaluated in a processor dependent order. Thereafter, the execution sequence proceeds to the first executable construct appearing within the scoping unit of the procedure after the invoked entry point. "o Completion of execution of a procedure is described in subclauses 12.5.3, 12.5.4, and 12.6.2.7. When a procedure completes execution, the execution sequence continues by continuing execution of the statement that caused the procedure to be invoked \obs{unless execution of the procedure is completed by branching to an alternate return specifier (12.6.2.7)}. "NOTE 2.6a Continuing execution of the statement that caused a procedure to be invoked might consist of nothing more than completing execution of that statement, or it might consist of further actions such as evaluation of operations in an expression, further data transfer, additional assignments, additional finalizations, etc., which in turn might result in invocation of other procedures by that statement." [33:16 2.3.5p2] -------------------------------------------------------- Editor: After "DO constructs" in the second list item, insert "other than DO CONCURRENT constructs" or "that are not DO CONCURRENT constructs". [33:18+ 2.3.5p2] ------------------------------------------------------- Editor: Insert list items after the second one: "o A DO CONCURRENT construct (8.1.6) causes a to be executed a specified number of times. During each execution of the the sequence of execution proceeds as specified in this subclause, but the order of executions of the is not specified." "o A WHERE construct (7.2.3) causes s to be executed. During execution of a the sequence of execution proceeds as specified in this subclause, but the order of execution of the s is not specified." "o A FORALL construct (7.2.4) causes a to be executed a specified number of times. During each execution of the the sequence of execution proceeds as specified in this subclause, but the order of executions of the is not specified." [54:17+8 4.4.2.3: NOTE 4.8] -------------------------------------------- Editor: Replace "transfer of control" by "branch (8.2)". Index this occurrence of "branch" (this occurrence of "transfer of control" is not currently indexed). [132:23 6.7.3.2p2] ----------------------------------------------------- Editor: Replace "When ... statement" by "When a RETURN or END statement is executed". {We don't want the executable constructs after the point of execution of the procedure to start executing until after the allocatable variables are deallocated.} [171:20 8.1.2.1p1] ----------------------------------------------------- Editor: Replace "Transfer of control" by "Branching (8.2)" because "transfer of control" prohibits procedures from returning. Alternative returns are branches, so "Branching" covers that case correctly. 8.2.1 explicitly says that there are transfers of control that are not branches. The two other occurrences of "transfers" in this paragraph are correct. [171:22 8.1.2.1p2] ----------------------------------------------------- Editor: Delete 8.1.2.1p2 because it is repetitive of 2.3.5, and contradicting 8.1.2.1p1 is no longer necessary. [176:36-38 8.1.6.4p1] -------------------------------------------------- Editor: Replace the paragraph by "The <> of a block DO construct is the ." The remainder of the paragraph is repetitive of 8.1.2.1p1. At least replace "transfer of control" by "branching (8.2)" and index this occurrence of branch (this occurrence of "transfer of control" is not currently indexed). [176:42 8.1.6.4p2] ----------------------------------------------------- Editor: Replace "transfer of control" by "branching (8.2)" because "transfer of control" prohibits procedures from returning. Index this occurrence of "branch" (this occurrence of "transfer of control" is not currently indexed). [177:7 8.1.6.6.1p1] ---------------------------------------------------- Editor: After "DO statement" insert "other than a DO CONCURRENT statement" or "that is not a DO CONCURRENT statement". [178:20-23 8.1.6.6.3p5]------------------------------------------------- Editor: Replace the first "transfer of control" by "branch (8.2)" the second by "branching" or "a branch", and the third by "branch". Index these occurrences of "branch" (these occurrences of "transfer of control" are not currently indexed). [188:3-4 8.2.1p1] ------------------------------------------------------ Editor: Replace the first two sentences ("Branching ... same scoping unit") to use the definition of execution sequence in 2.3.5: "A <> alters the normal execution sequence (2.3.5). When a branch occurs, the next statement executed is the branch target statement, in the same scoping unit, that is labeled by the label in the branch, instead of the one that would be executed by continuing the normal execution sequence." [188:7 8.2.1p1] -------------------------------------------------------- Editor: Replace "cause transfer of control" by "change the normal execution sequence". [188:16-17 8.2.2p1] ---------------------------------------------------- Editor: Replace the paragraph by: "Execution of a <> causes a branch to the branch target statement identified by the label." {Use the definitions of "branch" and "branch target statement" in 8.2.1.} [188:23 8.2.3p1] ------------------------------------------------------- Editor: Replace "a transfer of control ... is the one" by "a branch occurs to the branch target statement" {Use the definitions of "branch" and "branch target statement" in 8.2.1.} [188:31-32 8.2.4p1] ---------------------------------------------------- Editor: Replace "transfer of control" by "branch". Insert "is the one" before "identified". Replace "is executed next" by a comma. The result is "The branch target statement is the one identified by the first label, the second label, or the third label, depending on...." {Use the definitions of "branch" and "branch target statement" in 8.2.1.} [313:29-30 12.6.2.7p1] ------------------------------------------------- Editor: Replace "transfers control to the" by "branches (8.2) to the branch target". Replace "transfer of control" by "branch". Index these appearances of "branch". {Use the definitions of "branch" and "branch target statement" in 8.2.1.} [606] ------------------------------------------------------------------ Editor: Replace the index items "transfer of control" by "branch", especially the ones on pp 243-244, because they actually use the term "branch". I think the editorial instructions above accomplish this, but it wouldn't hurt to check.