Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zbeekman opened this issue Jul 26, 2017 · 5 comments

Comments

@zbeekman
Copy link
Member

zbeekman commented Jul 26, 2017

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
Copy link
Member Author

Can anyone think of additional alternatives?

@cmacmackin
Copy link

cmacmackin commented Jul 26, 2017 via email

@zbeekman
Copy link
Member Author

zbeekman commented Jul 26, 2017 via email

@rouson
Copy link

rouson commented Jul 28, 2017

2 is the way to go for the reasons stated.

@zbeekman
Copy link
Member Author

zbeekman commented Aug 3, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants