[comp.lang.fortran] Are GOTOs restricted in Fortran 88

whit@pitt.UUCP (Debbie Whitfield) (10/28/88)

    I would like to know if the standard permits GOTOs to jump into
control structures; loops, if-then-elses, or procedures.  
    
Thanks in advance for your information.

--------------------------------------------------------------------------
Debbie Whitfield	UUCP:      psuvax1!pitt!whit or {allegra,cadre}!...
Univ. of Pittsburgh		   whit@pitt.uucp
Computer Science Dept.	Internet:  whit@vax.cs.pittsburgh.edu
320 Alumni Hall		CSNET:     whit@pitt.csnet
Pittsburgh, PA 15260	

hirchert@uxe.cso.uiuc.edu (11/02/88)

Debbie Whitfield(whit@pitt.UUCP) asks
>/* ---------- "Are GOTOs restricted in Fortran 88" ---------- */

>    I would like to know if the standard permits GOTOs to jump into
>control structures; loops, if-then-elses, or procedures.  
>    
>Thanks in advance for your information.

. FORTRAN 77 prohibited jumps into DO-loops.  This restriction was retained in
  Fortran 8x and extended to apply to the new forms of DO loops as well.
. FORTRAN 77 prohibited jumps into block-IF constructs from outside the
  construct with the "exception" that a branch to the END IF statement is
  permitted (and, in effect, equivalent to branching to a CONTINUE statement
  following the END IF statement).  Fortran 8x has the same rules for block-IF,
  but flags the "exception" as obsolescent, so it might be removed in Fortran
  9x.  Fortran 8x also prohibits jumps into its other block constructs in
  in general.
. Both FORTRAN 77 and Fortran 8x prohibit jumps into or out of a procedure.
  (In Fortran 8x, this applies to internal procedures and module procedures as
  well as the external procedures of FORTRAN 77.)

Kurt W. Hirchert     hirchert@ncsa.uiuc.edu
National Center for Supercomputing Applications

campbell@aero.ARPA (L. Andrew Campbell) (11/11/88)

In article <50500088@uxe.cso.uiuc.edu> hirchert@uxe.cso.uiuc.edu writes:
>
>Debbie Whitfield(whit@pitt.UUCP) asks
>>/* ---------- "Are GOTOs restricted in Fortran 88" ---------- */
>
.... and he answers:
>. FORTRAN 77 prohibited jumps into DO-loops.  This restriction was retained in
>  Fortran 8x and extended to apply to the new forms of DO loops as well.
>Kurt W. Hirchert     hirchert@ncsa.uiuc.edu
>National Center for Supercomputing Applications

This is the 2nd time I have seen this statement made. Actually, one can jump
into the lexical range of a DO statement, provided one has jumped out of the
same DO. This is the old concept of "extended range" of a DO. The newer
terminology is: one is permitted to jump into an "active" do (one currently
being executed), and jumping out of a DO loop does not "inactivate" it. I
checked this information against a recent vendor-supplied manual, not against
the ANSI standard, but my recollection is that the ANSI standard permits the
above (i.e. it is not a vendor extension).

mikel@pyrps5 (Mike Lipsie) (11/12/88)

In article <41017@aero.ARPA> campbell@aero.UUCP (L. Andrew Campbell) writes:
>In article <50500088@uxe.cso.uiuc.edu> hirchert@uxe.cso.uiuc.edu writes:
>>
>>Debbie Whitfield(whit@pitt.UUCP) asks
>>>/* ---------- "Are GOTOs restricted in Fortran 88" ---------- */
>>
>.... and he answers:
>>. FORTRAN 77 prohibited jumps into DO-loops.  This restriction was retained in
>>  Fortran 8x and extended to apply to the new forms of DO loops as well.
>
>This is the 2nd time I have seen this statement made. Actually, one can jump
>into the lexical range of a DO statement, provided one has jumped out of the
>same DO. This is the old concept of "extended range" of a DO. The newer
>terminology is: one is permitted to jump into an "active" do (one currently
>being executed), and jumping out of a DO loop does not "inactivate" it. I
>checked this information against a recent vendor-supplied manual, not against
>the ANSI standard, but my recollection is that the ANSI standard permits the
>above (i.e. it is not a vendor extension).

Sorry to have to correct you, but since I just lost this argument I thought
I would share my joy. :-)

ANSI FORTRAN 77 11.10.2 "Active and Inactive DO-Loops." states:

   Once active, the DO-loop becomes inactive only when:

   ...

      (3) control is transferred to a statement that is in the
	  same program unit and is outside the range of the DO-
	  loop,

   ...

The range of a DO-loop is defined  (in 11.10.1) as all the statements
between the DO statement and the terminating statement.

Thus, the extended range was deleted.  However, many vendors kept the
extended range as an extension (they wanted to keep their customers happy).

-----------
Mike Lipsie  {allegra,cmcl2,decwrl,hplabs,ut-sally,utzoo}!pyramid!mikel
Pyramid Technology Corp, Mountain View, CA  +1 415 965 7200 ext. 4980

khb%chiba@Sun.COM (Keith Bierman - Sun Tactical Engineering) (11/12/88)

In article <41017@aero.ARPA> campbell@aero.UUCP (L. Andrew Campbell) writes:

> old question about extended do, with the old answer that it
> is not in x3.9-1978.

>This is the 2nd time I have seen this statement made. Actually, one can jump
>into the lexical range of a DO statement, provided one has jumped out of the
>same DO. This is the old concept of "extended range" of a DO. The newer
>terminology is: one is permitted to jump into an "active" do (one currently
>being executed), and jumping out of a DO loop does not "inactivate" it. I
>checked this information against a recent vendor-supplied manual, not against
>the ANSI standard, but my recollection is that the ANSI standard permits the
>above (i.e. it is not a vendor extension).

It IS a vendor extension. The ANSI document (page A-2 item 7 line 40)
states this unequiviocally.

"This standard does not permit a transfer of control into the range of
a DO loop from outside the range. The range of a DO loop may be
entered only by the execution of a DO statement. ANSI x3.9-1966
permitted transfer of control into the range of a DO loop under
certain conditions. This involved the concept referred to as "extended
range of a DO".

f77's failure to be 100% f66 compliant is why the f88 committee went
to great lengths to not make the same mistake. Hence all f77 compliant
programs are f88 complaint.
Keith H. Bierman
It's Not My Fault ---- I Voted for Bill & Opus

jerry@violet.berkeley.edu ( Jerry Berkman ) (11/12/88)

In article <41017@aero.ARPA> campbell@aero.UUCP (L. Andrew Campbell) writes:
>... Actually, one can jump
>into the lexical range of a DO statement, provided one has jumped out of the
>same DO. This is the old concept of "extended range" of a DO.

ANSI FORTRAN 77 standard, section 11.10.8:
	"Transfer of control into the range of a DO-loop from outside the
	range is not permitted."
section 11.10.1:
	"The range of a DO-loop consists of all of the executable statements
	that appear following the DO statement that specifies the DO-loop,
	up to and including the terminal statement of the DO-loop.

	- Jerry Berkman, UC Berkeley, jerry@violet.berkeley.edu

rpandey@mist.cs.orst.edu (Rajeev Pandey) (11/13/88)

 Would someone be kind enough to post/e-mail me a copy of FORTRAN 88 changes 
 or just point me at a good reference? I remember very foggily a journal 
 article of all the changes, but I can't remember or track it down, and now
 I need it.........
		      Thanx in advance,


--------                                        Rajeev "Raju" Pandey
Dept. of Computer Science   
Oregon State University               Internet: rpandey@cs.orst.edu
Corvallis, OR  97331-3902             UUCP:     tektronix!orstcs!rpandey
(503) 754-3273                        UUCP:     hplabs!hp-pcd!orstcs!rpandey