(j3.2006) IMPLICIT NONE in BLOCK
Malcolm Cohen
malcolm
Fri Feb 23 03:33:47 EST 2018
That is a perfectly good standard-conforming program, for which the standard supplies an interpretation.
>Another processor printed 0.0000000E+00 until I compiled with undefined
>variable checking turned on, after which it announced that the variable
>referenced in the print statement was undefined.
Compiler bugs only prove someone made a mistake.
>Either way, the variable X clearly is implicitly typed as real. The
>processors disagree whether X has inclusive scope,
The standard explicitly states that local variables have inclusive scope.
Lacking an explicit declaration, it is not a construct entity.
There is no problem In The Standard. That introducing block-endblock would introduce stupid bugs like that in the absence of inclusive scope is PRECISELY why we added inclusive scope.
>What Vipul Parekh was advocating
is breaking the model of how BLOCK is supposed to work. If it worked like that I and many other people would have voted it down into oblivion, as it would violate our duty not to introduce features that are highly error-prone.
> in a BLOCK construct, which would make this program invalid because X is
>not declared in either BLOCK construct, which is exactly what is
>desired.
No it is Absolutely Not what is desired.
>As Vipul pointed out,
erroneously.
Turning BLOCK into an irregular program-breaker is absolutely not acceptable.
>a good way to introduce them without fear of
>colliding with other variables would be to declare any newly-needed
>variables in BLOCK constructs.
And better ways are
(1) to explicitly declare the host variables and use IMPLICIT NONE in the first place (this is not difficult though it might be tedious if you have a single subprogram many thousands of lines long);
(2) to use a procedure
>An IMPORT, NONE statement alone doesn't solve this problem. I don't see
>a way that allowing IMPLICIT NONE in a BLOCK construct could affect a
>program that conforms to the 2018 standard.
Apart from preventing it from compiling, which we certainly do not want.
IMPORT,NONE by itself is sufficient anyway, because NOTHING is implicitly declared to be a block construct entity, you only get one of those by explicit declaration. 19.4 sets out all the ways to get construct and statement entities and ?using a variable in a construct sometimes magically makes it a construct entity instead of a local entity? is not one of them.
Similarly IMPORT,ONLY.
(Frankly, seeing IMPORT,NONE in a BLOCK would make me think the code ought to be a separate procedure since it has access to nothing from the host, but that?s a horse of a different colour.)
Cheers,
--
................................Malcolm.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.j3-fortran.org/pipermail/j3/attachments/20180223/37fdf2fe/attachment-0001.html>
More information about the J3
mailing list