(j3.2006) USE and BLOCK contructs
Robert Corbett
rpcorbett
Thu Oct 12 23:30:42 EDT 2017
Perhaps I made my example too concise.
The USE statement in BLOCK A makes the variable X in module VARaccessible 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 moduleVAR 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, namelythe inclusive scope consisting of the scoping units for themain program and the block.? Therefore, the scope of the localidentifier X in the block includes the scoping unit of the mainprogram.? 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 scopeof the main program, the local identifier X in the main programidentifies the same entity as it does in the block.? Therefore,the local identifier X in the main program is use associatedwith the variable X in module VAR.
My reading of the existing and draft standards is that it wouldmake no difference if I placed a gratuitous use of X in the block.That the scope of local identifiers is an inclusive scope and thatidentifiers of entities that are use associated are localidentifiers are all that is required.
Robert Corbett
?
On Thursday, October 12, 2017 6:56 PM, Malcolm Cohen <malcolm at nag-j.co.jp> wrote:
#yiv8107719523 #yiv8107719523 -- _filtered #yiv8107719523 {panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv8107719523 {panose-1:2 11 4 0 0 0 0 0 0 0;} _filtered #yiv8107719523 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered #yiv8107719523 {font-family:Verdana;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered #yiv8107719523 {panose-1:2 11 4 0 0 0 0 0 0 0;}#yiv8107719523 #yiv8107719523 p.yiv8107719523MsoNormal, #yiv8107719523 li.yiv8107719523MsoNormal, #yiv8107719523 div.yiv8107719523MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:11.0pt;}#yiv8107719523 a:link, #yiv8107719523 span.yiv8107719523MsoHyperlink {color:#0563C1;text-decoration:underline;}#yiv8107719523 a:visited, #yiv8107719523 span.yiv8107719523MsoHyperlinkFollowed {color:#954F72;text-decoration:underline;}#yiv8107719523 p.yiv8107719523msonormal0, #yiv8107719523 li.yiv8107719523msonormal0, #yiv8107719523 div.yiv8107719523msonormal0 {margin-right:0cm;margin-left:0cm;font-size:11.0pt;}#yiv8107719523 p.yiv8107719523style1, #yiv8107719523 li.yiv8107719523style1, #yiv8107719523 div.yiv8107719523style1 {margin-right:0cm;margin-left:0cm;font-size:11.0pt;}#yiv8107719523 span.yiv810771952320 {color:windowtext;}#yiv8107719523 .yiv8107719523MsoChpDefault {font-size:10.0pt;} _filtered #yiv8107719523 {margin:99.25pt 3.0cm 3.0cm 3.0cm;}#yiv8107719523 div.yiv8107719523WordSection1 {}#yiv8107719523 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 ? ?DisclaimerThe 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.j3-fortran.org/pipermail/j3/attachments/20171013/4ef4becd/attachment-0001.html>
More information about the J3
mailing list