Fortran-202X-Proposals icon indicating copy to clipboard operation
Fortran-202X-Proposals copied to clipboard

GENERAL CONCEPT: How to discourage/remove implicit save & streamline variable initialization?

Open zbeekman opened this issue 8 years ago • 5 comments

My proposal in #12 was infeasible as @milancurcic pointed out.

So far two possible options are

  1. Make obsolescent variable initialization during declaration (because these variables get the implicit save attribute

  2. Add an additional attribute to allow variable initialization during declaration that would make the variable a non-saved variable.

In my opinion the number one draw back of Fortran is its verbosity (including a lack of generic programming facilities). Disallowing variable initialization during variable declaration (1) will necessitate an additional line of code to perform the initialization assignment, and adding an extra attribute (2) to prevent implicit save still necessitates more typing.

Upon further consideration, (2) has now become my preference since multiple variables could be declared and initialized on the same line, requiring the addition of only 1 extra word (the new attribute). IMO this is more compatible with the "don't repeat yourself" (DRY) principle.

zbeekman avatar Jul 26 '17 17:07 zbeekman

Can anyone think of additional alternatives?

zbeekman avatar Jul 26 '17 17:07 zbeekman

The only other thing would be the standard requiring a compiler flag to turn off the implicit-save behaviour. This is hardly ideal and I also doubt they would go for it.

On 26/07/17 13:14, zbeekman wrote:

Can anyone think of additional alternatives?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Fortran-FOSS-Programmers/Fortran-202X-Proposals/issues/15#issuecomment-318121139, or mute the thread https://github.com/notifications/unsubscribe-auth/AHxJPaFa_iZExIfhpXzZb4CpHUUL_CQ0ks5sR3PcgaJpZM4OkOR1.

-- Chris MacMackin cmacmackin.github.io http://cmacmackin.github.io

cmacmackin avatar Jul 26 '17 19:07 cmacmackin

Yes, since they don't even acknowledge the existence of computers or compilers (just "processors") I see this as unlikely... But I agree, it would be great if a flag were provided for this.

On Wed, Jul 26, 2017 at 3:03 PM Chris MacMackin [email protected] wrote:

The only other thing would be the standard requiring a compiler flag to turn off the implicit-save behaviour. This is hardly ideal and I also doubt they would go for it.

On 26/07/17 13:14, zbeekman wrote:

Can anyone think of additional alternatives?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < https://github.com/Fortran-FOSS-Programmers/Fortran-202X-Proposals/issues/15#issuecomment-318121139>,

or mute the thread < https://github.com/notifications/unsubscribe-auth/AHxJPaFa_iZExIfhpXzZb4CpHUUL_CQ0ks5sR3PcgaJpZM4OkOR1 .

-- Chris MacMackin cmacmackin.github.io http://cmacmackin.github.io

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Fortran-FOSS-Programmers/Fortran-202X-Proposals/issues/15#issuecomment-318151264, or mute the thread https://github.com/notifications/unsubscribe-auth/AAREPPwen-olKZe0YkvY18EIsHpTXgO3ks5sR42EgaJpZM4OkOR1 .

zbeekman avatar Jul 26 '17 20:07 zbeekman

2 is the way to go for the reasons stated.

rouson avatar Jul 28 '17 05:07 rouson

Moved Damian's comment on old closed thread here:

On July 21, 2017 at 2:56:17 PM, zbeekman ([email protected]) wrote:

I have never met anyone who told me they need, want, or use the implicit save attribute attached to assigning default values during variable declaration. Although, in the case of modules, I think maybe it should stay? TBH, I'm confused by the semantics of save module variables.

The status of module variables was ambiguous in Fortran 95. Fortran 2003 cleared things up by making the SAVE attribute the default for module variables. Given that there does not exist a NOSAVE attribute at the present, that means all module variables have the SAVE attribute. I guess that’s really the only thing that makes sense. Otherwise, it’s not clear when and how they would go out of scope.

D

zbeekman avatar Aug 03 '17 23:08 zbeekman