Next: Generics and Specifics, Previous: %REF(), Up: Functions and Subroutines
%DESCR()
Construct%DESCR(arg)
The %DESCR()
construct specifies that an argument,
arg, is to be passed by descriptor, instead of by
value or reference.
%DESCR()
is restricted to actual arguments in
invocations of external procedures.
Use of %DESCR()
is recommended only for code that
is accessing facilities outside of GNU Fortran, such as
operating system or windowing facilities.
It is best to constrain such uses to isolated portions of
a program—portions the deal specifically and exclusively
with low-level, system-dependent facilities.
Such portions might well provide a portable interface for
use by the program as a whole, but are themselves not
portable, and should be thoroughly tested each time they
are rebuilt using a new compiler or version of a compiler.
Do not depend on %DESCR()
supplying a pointer
and/or a length passed by value
to the procedure being invoked.
While that is a likely implementation choice, other
implementation choices are available that preserve the
pass-by-reference semantics without passing a pointer to
the argument, arg.
(For example, a copy-in/copy-out implementation.)
And, future versions of g77 might change the
way descriptors are implemented, such as passing a
single argument pointing to a record containing the
pointer/length information instead of passing that same
information via two arguments as it currently does.
Implementation Note: Currently, g77 passes
all variables and arrays of type CHARACTER
by descriptor.
Future versions of, or dialects supported by, g77 might
pass CHARACTER
functions by descriptor as well.
Thus, use of %DESCR()
tends to be restricted to cases
where arg is not type CHARACTER
but the called
procedure accesses it via a means similar to the method
used for Fortran CHARACTER
arguments.
See Procedures (SUBROUTINE and FUNCTION), for detailed information on how this particular version of g77 passes arguments to procedures.