J3/04-373
Date: 12 August 2004
To: J3
From: Bill Long
Subject: Interoperability of optional arguments
Number:
Title: Interoperability of optional arguments
Submitted By: J3
Status: For consideration
Basic Functionality:
Extension to C Interop that allows optional arguments to be
interoperable.
Rationale:
If C functions have a mechanism to indicate and detect missing
optional arguments, the class of Fortran subprograms that interoperate
with C would be significantly expanded.
Estimated Impact:
Small impact for the standard and probably small to moderate
impact for the processors.
Detailed Specification:
The VALUE attribute is not allowed for optional dummy arguments in a
BIND(C) interface.
A C function specifies a missing actual argument in a function
reference by passing a NULL data pointer as the argument value if the
corresponding dummy argument is a data object, or a NULL procedure
pointer as the argument value if the corresponding dummy argument is
a procedure. If the function being referenced is a Fortran procedure,
the corresponding dummy argument must have the OPTIONAL attribute, and
the procedure must have the BIND(C) attribute.
A Fortran subprogram with the BIND(C) attribute specifies a missing
actual argument in a subroutine call or function reference by passing
C_NULL_PTR by value for a missing data argument and C_NULL_FUNPTR by
value for a missing procedure argument. The OPTIONAL attribute must
be specified for the corresponding dummy argument. The C function can
detect a missing argument by comparing its value to NULL.
History: Submitted as paper 04-373 at meeting 169.