(j3.2006) IMPLICIT NONE in BLOCK

Van Snyder van.snyder
Fri Feb 23 15:54:45 EST 2018


On Fri, 2018-02-23 at 20:26 +0000, Steidel, Jon L wrote:
> Van wrote:  
>    I haven't been able to ask any processors what they think about
> 
>     program foo
>        block
>             import, none
>             x = 42
>             print *, x
>        end block  
>     end program foo
> 
> 
> one implementation I have access to treats this as a valid code; it
> compiles without error and prints 42.00000.  If an IMPLICIT NONE is
> inserted after the PROGRAM statement, the first use of X triggers an
> error from  the compiler for an undeclared variable.  If an inner
> BLOCK is nested inside the block construct, X is accessible there, but
> is not accessible outside the outer block construct. 

My understanding of inclusive scope, about which Malcolm might correct
me, is that X is a local entity of the program, not a construct entity,
and is therefore not accessible within the BLOCK construct because of
the IMPORT, NONE statement.  Seems weirdly unintuitive because X doesn't
appear anywhere else.  If this interpretation is correct, some ink in
textbooks and a note in the standard would be helpful.

We shouldn't have done inclusive scope.  We did it for labels.  We
should have used host association for BLOCK constructs, and made labels
accessible by host association, but only in constructs, not internal
procedures.  Labels in BLOCK constructs ought not to be accessible
outwith the constructs.  We should undo it while the damage of undoing
it is minimal.  Variables that appear only in blocks ought to be
construct entities of those blocks, not local entities of the inclusive
scope.  Ones with the same identifier that appear in several blocks
ought to be different construct entities.  Programs that depend upon
such variables being local entities, and ones that refer from outwith
the block to labels of format statements that appear in blocks are the
only ones that would need attention if we changed to host association.

Since BLOCK doesn't use host association to access the local scope,
perhaps IMPORT,NONE shouldn't have been done for BLOCK, or at least
spelt differently.





More information about the J3 mailing list