Since one can write
INTEGER::X
X=0
and mean set the "initial" value on entry to 0 which is different from
INTEGER::X=0
set the value at the start of the program rather than the entry gave simple
way to express two different and useful functionalities we oldies chose to
make declared initialisation mean saved.
What we lack is a way of stating that a local value is to be constant for
an invocation but possibly different for different invocations, but this is
a minority interest!
--On 14 January 2006 09:24 -0500 Aleksandar Donev
<[log in to unmask]> wrote:
> David,
>
> I believe that module variables that are initialized, as in
> integer :: x=0
> will automatically get SAVEd, though I don't have the standard right here
> at the moment. Certainly local variables in procedures do. This I suspect
> is a historical legacy that must be kept due to backward compatibility. I
> consider it a very bad "feature". Namely, there is a perfectly reasonable
> semantics to a local procedure variable not being saved---the variable
> gets (re)initialized every time the procedure is executed. In fact, this
> is what the standard does for local variables of derived type that has
> default initialized components (which btw is a Fortran 95 feature,
> probably the only important one :-). So I suspect that module variables
> were done so that they behave similarly to procedure local variables, but
> I was too young back then to remember :-)
>
> I often miss the ability to have local procedure variables that get
> reinitialized every time the procedure executes. One can of course do it
> by putting the initialization as the first executable statement in the
> procedure body, but why? Again, I suspect in the good old days when all
> local vars were static and not on the stack it made sense to implicitly
> give them the SAVE attribute. It certainly makes no sense to me today...
>
> Best,
> Aleks
>
> --
--
Lawrie Schonfelder
Home: 1 Marine Park, West Kirby, Wirral, UK, CH48 5HN
Phone: +44 (151) 625 6986
Mobile: +44 (0) 7885657457
|