[J3] Question involving explicit initialization

Malcolm Cohen malcolm at nag-j.co.jp
Sat May 4 20:12:49 EDT 2019


>SAVE might carry the implication of a "global entity"

I cannot understand why anyone would think that, given that we have a precise definition of “global entity” and SAVE does not enter into it in the slightest.

>would a phrase "more than once in a *scoping unit*" 

No, that would be completely wrong.

The requirement is precisely that a variable only be explicitly initialised once in the program.

For variables outside of COMMON, there is no way to initialise them more than once (the rules  that prevent it are at the syntax level).  But for variables in COMMON, the syntax does not prevent that: only this rule does.

Cheers,

From: Vipul Parekh via J3 
Sent: Sunday, May 5, 2019 8:11 AM
To: General J3 interest list 
Cc: Vipul Parekh 
Subject: Re: [J3] Question involving explicit initialization

On Sat, May 4, 2019 at 3:17 PM Robert Corbett via J3
<j3 at mailman.j3-fortran.org> wrote:
>
> Bill has it right. Subroutines are scoping units. The name "i" identifies one variable in one subroutine, and a different variable in the other subroutine.
>
> If the variable "i" was declared in the scope of the module and the name "i" was not redeclared in the subroutines, the name "i" would still refer to different entities in the subroutines, but they would both be host associated with the variable "i" in the scope of the module.
> ..

Thank you all for your feedback.

My question was based on my confusion "once in a program" and if there
was any connection here with variables that have the SAVE attribute
such as 'i'. I thought SAVE might carry the implication of a "global
entity" due to a 'static variable' status, at least with some
implementations, and I was wondering whether that had any bearing.

So now, is the sentence in the standard document sufficiently precise:
"A variable, or part of a variable, shall not be explicitly
initialized more than once in a program"? Or would a phrase "more
than once in a *scoping unit*" more clearly capture the responsibility
of the coder at to where a variable "shall not be explicitly
initialized more than once"

Regards,
Vipul Parekh



Disclaimer

The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. Please see our Privacy Notice for information on how we process personal data and for details of how to stop or limit communications from us.

This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190505/0405bc6a/attachment-0001.html>


More information about the J3 mailing list