(j3.2006) USE and BLOCK contructs
Van Snyder
Van.Snyder
Fri Oct 13 14:18:02 EDT 2017
The relationship between blocks and their enclosing scopes ought to have
been the same as host association. Inclusive scope should have applied
only to labels, and probably only to labels of FORMAT statements.
On Fri, 2017-10-13 at 03:30 +0000, Robert Corbett wrote:
> Perhaps I made my example too concise.
>
>
> The USE statement in BLOCK A makes the variable X in module VAR
> accessible in the block. Paragraph 7 of subclause 14.2.2 [298:3]
> "The USE statement and use association" states
>
>
>
> An accessible entity in the referenced module has
> one or more local identifiers.
>
>
> In my example, the local identifier of the variable X in module
> VAR in the block is the name X. Paragraph 2 of subclause 19.1
> [513:4-9] "Scopes, identifiers, and entities" states
>
>
> The scope of ... a local identifier is an inclusive
> scope ... excluding any nested scope where the identifier
> is treated as the identifier of a different entity
> (19.3, 19.4).
>
>
> There is only one inclusive scope in the main program, namely
> the inclusive scope consisting of the scoping units for the
> main program and the block. Therefore, the scope of the local
> identifier X in the block includes the scoping unit of the main
> program. Paragraph 4 of subclause 19.1 [515:1] states
>
>
> A local identifier identifies an entity in a scope ...
>
>
> Because the scope of the local identifier X includes the scope
> of the main program, the local identifier X in the main program
> identifies the same entity as it does in the block. Therefore,
> the local identifier X in the main program is use associated
> with the variable X in module VAR.
>
>
>
> My reading of the existing and draft standards is that it would
> make no difference if I placed a gratuitous use of X in the block.
> That the scope of local identifiers is an inclusive scope and that
> identifiers of entities that are use associated are local
> identifiers are all that is required.
>
>
> Robert Corbett
>
>
>
>
>
> On Thursday, October 12, 2017 6:56 PM, Malcolm Cohen
> <malcolm at nag-j.co.jp> wrote:
>
>
>
> Hi Robert,
>
> I do not follow your reasoning at all. X is not accessed by use or
> host association, and is therefore a local variable of MAIN, which
> makes the program nonconforming as X is not defined. I think it
> unlikely to print the value 1.0?
>
> What text exactly are you looking at here?
>
> Cheers,
> --
> ..............Malcolm Cohen, NAG Oxford/Tokyo.
>
> From: J3 [mailto:j3-bounces at mailman.j3-fortran.org] On Behalf Of
> Robert Corbett
> Sent: Friday, October 13, 2017 9:03 AM
> To: J3 List <j3 at j3-fortran.org>
> Subject: (j3.2006) USE and BLOCK contructs
>
> While I disagree entirely with the discussion and proposed edits
> in paper 17-184, there is a related issue I find concerning.
> Consider the program
>
> MODULE VAR
> REAL :: X = 1.0
> END MODULE VAR
>
> PROGRAM MAIN
> PRINT *, X
> A: BLOCK
> USE VAR
> END BLOCK A
> END PROGRAM MAIN
>
> The variable X is not explicitly declared in the BLOCK construct,
> so it is a local identifier, not the name of a construct entity.
> Therefore, its scope includes the scoping unit of the main program.
> Therefore, the program appears to be conformant, and it should print
> something like
>
> 1.0
>
> Was this intended?
>
> The text of Fortran 2008 and the current Fortran 2015 draft are
> consistent and seem clear on this point, but I still have doubts
> that such a program was intended be conformant.
>
> Robert Corbett
>
>
> 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.
>
> 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.
>
>
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
More information about the J3
mailing list