(j3.2006) COPY mode of argument association
Van Snyder
Van.Snyder
Thu Dec 17 15:58:42 EST 2015
We have VALUE, which is a copy-in mode of argument association.
I was recently asked to figure out why a recursive tree-building routine
didn't work for some sizes of inputs.
During the building process, if it ran out of space, it would double the
space and copy the work into it.
The recursion involved passing a tree vertex into the recursive
invocation, which then filled in the location of its newly-created
vertex as the parent vertex's son.
The reason it didn't work sometimes was that the address was computed
before the recursive invocation. If the recursive invocation
reallocated the tree, the actual argument was no longer there. Of
course, this violated the "no change to the actual argument except via
the dummy argument" dictum.
The solution was to pass the location of the child vertex back as a
function argument. I hope processors don't calculate the address of the
function result and pass that as a hidden argument for the function to
use to store its result value.
This wouldn't have been a problem if we had had a copy-out mode of
argument association. Basically, we were too influenced by C
interoperability when we added VALUE. We should have spelt it COPY.
For INTENT(IN) it's copy-in, i.e., the same as VALUE. For INTENT(OUT)
it's copy-out. Othewrwise, it's copy-in/copy-out.
More information about the J3
mailing list