\documentclass[nocolor,memo]{j3}
\renewcommand{\hdate}{28 December 2003}
\renewcommand{\vers}{J3/04-148}
\usepackage{lineno}
\usepackage{longtable}
\usepackage{xr}
\externaldocument{007}
\input pdftest
\begin{document}
\vspace{-10pt}
\begin{tabbing}
Subject: \hspace*{0.25in}\=Internal subprograms as actual arguments and
procedure pointer targets\\
From: \>Van Snyder\\
Reference: \>03-258r1, section 1.7\\
\end{tabbing}
\pagewiselinenumbers
\leftlinenumbers
\linenumbers*
\section{Number}
TBD
\section{Title}
Internal subprograms as actual arguments and procedure pointer targets.
\section{Submitted By}
J3
\section{Status}
For consideration.
\section{Basic Functionality}
Allow internal subprograms as actual arguments and procedure pointer
targets.
\section{Rationale}
In many cases where one uses a subprogram as an actual argument, it needs
access to entities of which the procedure to which it is passed is
unaware. If the actual argument were an internal subprogram, it could
access these extra entities by host association.
If the 2003 standard does not require the TARGET attribute for a
nonpointer dummy procedure that is a procedure pointer target, we cannot
simultaneously allow internal procedures to be actual arguments and
prohibit them to be procedure pointer targets.
\section{Estimated Impact}
Small. Minor changes necessary in Sections 7, 12 and 16, and Annex C.
\section{Detailed Specification}
\subsection{Allow an internal subprogram to be an actual argument}
There are two possibilies concerning the host of the internal subprogram:
\begin{itemize}
\item Allow the host of the internal subprogram to be recursive. Make it
clear that accesses by host association from the internal subprogram to
entities of its host are accesses to entities in the instance of its
host as of the instant the internal subprogram was used as an actual
argument, not to entities in the instance of its host as of the instant
the internal subprogram is invoked.
If the internal procedure cannot be passed to a recursive invocation of
its host (which can sometimes be verified by analyzing the host's dummy
arguments) there can be no difference between these instances.
Nonetheless, there can still be more than one instance of the host.
Therefore, procedure arguments would need to have the extra overhead of
a pointer to the appropriate instance of the host of the actual
argument~--- even if the host is nonrecursive, because the called
procedure cannot efficiently know whether the host of an actual
argument associated with a dummy procedure is recursive. Since a
procedure that invokes a dummy procedure cannot efficiently know
whether the associated actual procedure is or is not an internal
procedure, there is extra overhead associated with every procedure
reference by way of a dummy procedure. Since a procedure cannot
efficiently know whether it is invoked by way of a dummy procedure,
there is extra overhead associated with every procedure refrence~---
even those having nothing to do with internal subprograms or dummy
procedures.
There is also extra overhead at every reference from an internal
subprogram to its host by host association if the host is recursive:
It needs to know to which instance of its host it is referring. Since
the internal procedure cannot know whether it is being invoked directly
or by way of a dummy procedure, the specification of the instance of
the host needs to be provided by the procedure invocation, not by some
other data structure (else one could get the wrong instance).
\item Require that the host of the internal subprogram is not recursive.
In this case, there can only be one instance of the procedure defined by
the host subprogram, so a pointer to the instance does not need to
accompany the argument. This restriction could later be relaxed.
\end{itemize}
\subsection{Allow an internal subprograms to be a procedure pointer target}
Similar considerations regarding recursive hosts apply. It is
unavoidable that the same restriction applies to internal subprograms
used as procedure pointer targets and used as actual arguments: A
procedure that has a dummy procedure cannot efficiently know whether the
actual argument is an internal procedure or a procedure pointer
associated with an internal procedure, and an internal subprogram cannot
efficiently know whether it is invoked directly, by way of a procedure
pointer, or by way of a dummy procedure.
If internal subprograms of recursive hosts are allowed to be procedure
pointers, make it clear that the instance of the host to which accesses
from the internal subprogram to that host by host association refer, when
it is invoked by way of the pointer, is the instance as of the instant
the procedure was associated with the pointer, not the instance as of the
instant the internal subprogram is invoked via the pointer.
Make sure that procedure pointers associated with an internal subprogram
become undefined when the instance of the procedure defined by its host
subprogram that was in existance at the instant the pointer association
was established ceases to exist.
\section{History}
\label{lastpage}
\end{document}