Path: utzoo!mnetor!uunet!hpda!hpesoc1!hpcllla!hpclisp!hpclcdb!cdb From: cdb@hpclcdb.HP.COM Newsgroups: comp.lang.fortran Subject: Re: Semantics of local variables Message-ID: <6690007@hpclcdb.HP.COM> Date: 2 Jan 88 05:36:10 GMT References: <2617@killer.UUCP> Organization: HP ITG/ISO Computer Language Lab Lines: 22 > A quick question for serious FORTRAN user's: do the semantics of initializing > a local variable in a DATA statement force the variable to have static > scope? That is, can you generally count on the variable retaining its value > across calls to the subroutine in which it's defined? I know this is the case > for some compilers, but can you count on it generally? F77 and no, I don't > have a copy of the standard. > The Fortran 77 standard says that you can't depend on it (Page 8-11, lines 33-42, if you want to look it up). As a practical matter, the compiler would have to go to a lot of trouble and produce a lot of extra code to break this assumption - I've only heard rumors of one compiler that didn't make these values saved. It supposedly did/does assignments to the initialized locals to implement DATA, thereby trashing any previously changed values - and slowing down the program unnecessarily. Given the availability of the SAVE statement in standard F77, why worry - SAVE it! Carl Burch hplabs!hpda!cdb