Fortran-FOSS-Programmers / Fortran-202X-Proposals

A place to collaborate on proposals for the next Fortran standard
21 stars 0 forks source link

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

Open zbeekman opened 7 years ago

zbeekman commented 7 years ago

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 commented 7 years ago

Can anyone think of additional alternatives?

cmacmackin commented 7 years ago

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

zbeekman commented 7 years ago

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 notifications@github.com 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 .

rouson commented 7 years ago

2 is the way to go for the reasons stated.

zbeekman commented 7 years ago

Moved Damian's comment on old closed thread here:

On July 21, 2017 at 2:56:17 PM, zbeekman (notifications@github.com) 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