Fortran assignment on declaration and SAVE attribute gotcha -


In Fortran 95, if you specify a variable on the declaration

  integer :: Var = 0  

this

  is equal to integer, save :: var = 0  

and so the variable Is protected after routine execution (C code has constant ) and it is not restarted when it is called again. (IMHO Dangerous) What is the logic behind the behavior / technical problem?

I do not think there is some logic behind such behavior.

But as far as I know, Stepheno, you used the wrong terminology. integer :: var = 0

     type declaration & amp; Initial integer :: var! Type declaration var = 0! Assignment  

It seems that this was just a committee design decision if we have such an expression (type declaration statement in parallelism), then this is not an initial assignment. And the initial program only happens once during the program (and processes) not executable.

However, there may be some historical reasons for such a decision. Take a look at the thread.

Today such behavior is dangerous because many other widely used languages ​​follow another conference about the initial / assignment.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -