(j3.2006) IMPLICIT NONE in BLOCK

Van Snyder van.snyder
Fri Feb 23 17:03:29 EST 2018


On Fri, 2018-02-23 at 13:17 -0800, Robert Corbett wrote:
> Please read the note added to page 124 in paper 17-253.  It covers
> this specific case.

OK, I found note 8.45 on page 123 of 18-007.  It explicitly says the
program is not conformant, as I suspected.  So whichever processors Jon
and Bill used might need repair.

IMPORT, ONLY is a bit more difficult to use to get the effect IMPLICIT
NONE would have had in a BLOCK if we had allowed it and used host
association instead of inclusive scope.  If you are forced to go to the
trouble to import each entity individually, you might as well go back to
the inclusive scope and declare them, which is what one might hope to
avoid by using IMPLICIT NONE in a block.

> 
> Robert Corbett
> 
> > On Feb 23, 2018, at 12:54 PM, Van Snyder <van.snyder at jpl.nasa.gov> wrote:
> > 
> >> 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.
> > 
> > 
> > _______________________________________________
> > J3 mailing list
> > J3 at mailman.j3-fortran.org
> > http://mailman.j3-fortran.org/mailman/listinfo/j3
> 





More information about the J3 mailing list