Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!ukc!edcastle!dtm From: dtm@castle.ed.ac.uk (D Muxworthy) Newsgroups: comp.lang.fortran Subject: Re: Is this a "feature"? Message-ID: <10573@castle.ed.ac.uk> Date: 27 May 91 12:15:41 GMT References: <1991May23.160841.402@ac.dal.ca> <24424@lanl.gov> Organization: Edinburgh University Lines: 40 In article <24424@lanl.gov> jlg@cochiti.lanl.gov (Jim Giles) writes: > >... In fact, >I seem to remember that in the 66 standard the definition status of a >local variable across calls was not even mentioned. Many implementations >(MOST) implemented all local variables statically - and so, many users >began to depend on that. Fortran 66 section 10.2.6 says: "Entities Not in Common. An entity not in common except for a dummy argument or the value of a function may be initially defined. [i.e. appear in a DATA statement]. Such entities once defined by any of the rules previous mentioned, remain defined until they become undefined. If such an entity is in a subprogram, the completion of execution of a RETURN statement in that subprogram causes all such entities and their associates [via EQUIVALENCE] at that time (except for initially defined entities that have not been redefined or become undefined) to become undefined. In this respect, it should be noted that the association between dummy arguments and actual arguments is terminated at the inception of execution of the RETURN statement." The reason for writing it this way was mainly to allow for programs possibly being overlaid. Those few compilers that put local variables on a stack conformed to the standard but in practice would not run the majority of programs from other systems which had been written on the (non-standard) assumption of static storage. In Fortran 66 there was thus no way of preserving the values of local variables after a RETURN, other than those in a DATA statement. The SAVE statement was introduced in Fortran 77 for that purpose, and also to preserve the values in a labelled common block throughout the execution of a program, without the block having to be declared in the main program (useful e.g. for subroutine package writers). David Muxworthy University of Edinburgh