glen herrmannsfeldt <
g...@ugcs.caltech.edu> wrote:
> Thomas Koenig <
tko...@netcologne.de> wrote:
> > - issue an unconditional warning for the call to inout(), because the
> > argument is not definable. Or maybe this should also be an error?
>
> Why is the argument not definable? inout means that the routine may
> or may not change it, and may or may not use the value on entry.
I think you may be misunderstanding either what "definable" means or
what the standard's requirements are. The standard requires that the
actual argument be definable if the dummy is intent(inout). That
requirement is completely independent of any question of whether the
dummy argument happens to get redefined; for inout, the standard
requires that the actual argument be definable regardless. Only for
unspecified intent do the requirements for the actual argument
definability depend in any way on whether the subroutine actual does
redefine the dummy.
I was going to say that the argument is not definable because the
standard says so. But on checking, I find, somewhat amusingly, that the
standard doesn't have a normative definition of "definable". There is a
definition in the glossary, but that definition is pretty vague, so I
looked for the normative one. It isn't there (at least in f2003).
If we go with the only thing there is, namely the one in the glossary,
it just says
"A variable is \tdef{definable}
if its value may be changed by the appearance of its designator on the
left of an assignment statement."
which I find a bit vague, and indeed almost circular. I *THINK* there is
an implication that definability as a property of a variable independent
of time or the particular place in the code. But it would be nice if
that were made explicit (and even nicer if it were nomative). IN
particular, I think this (non-normative) definition implies that if I is
a local variable that is definable outside of the loop, it is still
"definable" inside the loop because the definability of I doesn't
change. That's not to say that you are allowed to redefine I inside of
the loop (you aren't). Just that the term "definable" doesn't appear to
relate to whether you may redefine the value here, but instead that
there is anyplace where you could redefine it. I'll not stand behind
that deduction, but that's the way I think I read it.
So I conclude that the argument is "definable", even though you are not
allowed to redefine it in that particular place.
> I think, though, that there are way too many subroutine calls
> with DO variables, to have the warning on by default.
That's certainly so for subroutines with implicit interfaces. That
would, for example, include virtually all f77 code. Implicit interfaces
were the only possibility in 777, and I'd find it hard to imagine that
there were many f77 codes of significant size that didn't involve
passing DO variables as actual arguments somewhere or other.
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain