J3/04-236
Date: 2004-02-10
To: J3
From: fortran.com
Subject: Taming GO TO and arithmetic IF using the COME FROM Statement
Reference: Pub-119
This was submitted by Van Snyder van.snyder@jpl.nasa.gov
===========================================================
Number:
Title: Taming GO TO and arithmetic IF using the COME FROM Statement
Submitted by: J3
Status: For Consideration
References: Section 8 of 03-007r2
Basic Functionality: Add a COME FROM statement with the same execution
semantics as the CONTINUE statement -- not the INTERCAL COME
FROM statement -- that works with GO TO and arithmetic IF
statements as described in the "Specification" section
below.
Rationale: Adding a COME FROM statement could tame GO TO
and arithmetic IF.
Without COME FROM the control graph can be traced in a
forward direction only. With the COME FROM statement, it
can be traced in both directions. Answering the question
"How does control reach this point?" becomes much easier.
Estimated Impact: It is easy to implement.
It affects only the description of GO TO, computed GO TO
and arithmetic IF (constraints C830, C831 and C832).
It requires one more tiny subclause in or immediately
after 8.2.
It would not affect code generators, but could conceivably
simplify some analyses that optimizers do.
Detailed Specification: Add a COME FROM statement with syntax COME FROM .
If a COME FROM statement appears in a scoping unit, every
GO TO or arithmetic IF statement in the scoping unit, or
logical IF statement with one of those as a consequent,
shall have a label. Every label that appears in a GO TO
statement or an arithmetic IF statement shall be the label
of a COME FROM statement that includes the label of the
GO TO statement or arithmetic IF statement in its
.
The execution semantics of the COME FROM statement are the
same as for the CONTINUE statement.
This would much messier to explain, and much less useful,
if we still had ASSIGN and assigned GO TO.
Example:
5 COME FROM 25
...
10 IF ( TEST ) IF ( ABS(X-EPSILON(X)) - TOL ) 30, 30, 20
...
20 COME FROM 10
...
25 GO TO 5
30 COME FROM 10
History: Submitted as Pub-119