(j3.2006) C interoperability idea from a colleague
Malcolm Cohen
malcolm
Mon Apr 13 21:52:08 EDT 2015
>A colleague would like to reference a Fortran subroutine that has
>several optional arguments from C.
>
>I referred him to the "Further Interoperability" TS.
>
>He asked if he had to provide a descriptor for every argument, not just
>the ones that are present.
Not only do you not have to provide a descriptor, you are not ALLOWED to provide
a descriptor for any argument that is not present.
"If an interoperable procedure defined by means of Fortran is invoked by a C
function, an optional dummy argument is absent if and only if the corresponding
argument in the invocation is a null pointer."
>I said that's the way it is.
>
>He suggested that the descriptor ought to include the Fortran argument
>name, and the called Fortran subroutine ought to work out which
>arguments are present.
And how is it supposed to do that? The argument names are not characteristics
of a procedure. Whatever argument names are used in the procedure definition
has no necessary connection to the argument names used in an interface for that
procedure.
And there is no sentinel on an argument list to know when to stop reading
either.
Not to mention that even it if were possible, taking N**2 time to process the
argument list even before the procedure starts does not sound like a good idea.
>I don't know whether that's practical, or not incompatible with what we
>did, but it is interesting.
It's not compatible with argument names not being characteristics of the
procedure.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list