\documentclass[11pt,nocolor,memo]{j3}
\renewcommand{\hdate}{13 November 2002}
\renewcommand{\vers}{J3/02-324r1}
\usepackage{lineno}
\usepackage{longtable}
\usepackage{xr}
\externaldocument{007}
\ifx\pdfoutput\undefined
\usepackage[hypertex,plainpages,hyperindex=true]{hyperref}
\hypersetup{%
hypertexnames=false%
}
% Specify the driver for the color package, which package is included
% by the J3 document class using a RequirePackage command.
\ExecuteOptions{dvips}
%\ExecuteOptions{xdvi}
\else
\pdfoutput=1
\usepackage[pdftex,plainpages,hyperindex=true,pdfpagelabels]{hyperref}
\hypersetup{%
hypertexnames=false,%
colorlinks=true,%
linktocpage=true,%
}
% Specify the driver for the color package, which package is included
% by the J3 document class using a RequirePackage command.
\ExecuteOptions{pdftex}
\fi
\begin{document}
\vspace{-10pt}
\begin{tabbing}
Subject: \hspace*{0.25in}\=Module initialization\\
From: \>Van Snyder\\
\end{tabbing}
\pagewiselinenumbers
\leftlinenumbers
\linenumbers*
\section{Introduction}
Richard Maine has described an application that can be realized most
elegantly by automatic initialization of modules and submodules. It can
be realized without automatic initialization, but this increases both
maintenance and development costs.
To outline one small part of the problem that illustrates the utility of
automatic initialization, consider a program that will be augmented by
many users to support their needs. Their augmentation will consist of
adding new input routines, among other things; they should not need to
change the majority of the program.
Without automatic initialization, they would need to modify some part of
the existing program in order to add something to a data structure to
provide access to the new procedures.
If a facility of automatic initialization is provided, the user can
provide an additional module, extend a type, and use the initializer
to link an object of the extended type into a list. The main part of the
program can then access the new functionality, without any modifications
having been made to the main part of the program.
The augmentation is a little bit cleaner with submodule initializers
(because the ``add this to your list'' routine need not be public), but
submodule initializers allow subversion of the privacy of data in an
ancestor module. More severe restrictions than those on pure procedures
would be required to prevent this.
\section{Proposition}
Allow executable statements after the \si{specification-part} of a module
and before the \si{module-subprogram-part}. These statements are called
the {\bf module initializer}. This is analogous to where executable
statements are allowed in the main program or a subprogram.
The initializers of all modules upon which a program unit depends by use
association shall be executed before any \si{executable-construct} in the
\si{execution-part} of that program unit is executed, or any
specification expression in that program unit is evaluated. An
initializer shall not be executed more than once.
\edits{02-007r3}
\sep\mgpar{9:32+}
\bnfb{[ \si{execution-part} ]}
\sep\mgpar{13:14}[Editor: ``contains'' $\Rightarrow$ ``may contain'';
``accesses'' $\Rightarrow$ ``access''.]
\sep\mgpar{13:15}[Editor: ``units. These'' $\Rightarrow$ ``units, and may
contain an \si{execution-part}. The'']
\sep\mgpar{13:16+}The \si{execution-part} of a module is a \tdef{module
initializer}.
\sep\mgpar{14}[Editor: In the ``executable statement'' and ``FORMAT
statements'' rows of the MODULE column of table 2.2, change ``no'' to
``yes'' twice.]
\sep\mgpar{15:1}[Editor: After ``program.'' insert ``Executing an
\si{end-module-stmt} causes normal termination of execution of a module
initializer.'']
\sep\mgpar{15:3}The \si{end-block-data-stmt} statement is nonexecutable.
\sep\mgpar{15:5-11}Execution of a main program, a subprogram, or a module
initializer involves execution of the \si{executable-construct}s within
its scoping unit. With the following exceptions, the effect of execution
is as if the \si{executable-construct}s are executed in the order they
appear until a STOP, RETURN or END statement is executed. The exceptions
are the following:
\sep\mgpar{15:18+\\New \P}The initializers of all modules upon which a
program unit depends by use association or host association, either
directly or indirectly, shall be executed before any
\si{execution-construct} in the \si{execution-part} of that program unit
is executed, or any specification expression in that program unit that is
not an initialization expression is evaluated.
It is processor dependent whether the initializers of modules that are
not accessed by use association are executed.
An initializer shall not be executed more than once.
If a program contains a Fortran main program, execution of the program
begins by executing any necessary initializers, followed by execution of
the main program.
Execution of the main program or an initializer begins with the first
\si{executable-construct} of its \si{execution-part}. When a procedure
is invoked, execution begins with the first \si{executable-construct}
following the invoked entry point.
\sep\mgpar{15:20}[Editor: Add a sentence in the same paragraph: ``The
execution sequence of a module initializer excludes module procedures
within the module.'']
\sep\mgpar{246:3}[Editor: Insert ``' and may contain an
\si{execution-part}'' after ``units''.]
\sep\mgpar{246:9+}
\bnfb{[ \si{execution-part} ]}
\sep\mgpar{246:25+4}[Editor: In the first line of Note 11.4, replace the
first comma by ``and'' and delete ``, and FORMAT statements''.]
\sep\mgpar{431:3+}[Editor: Insert a new subclause before C.1:]
\vskip 5pt
{\Large\secfont C.1 Section 2 notes}
\vskip 5pt
A sequence of execution of module initializers that satisfies the
requirements in \ref{D2:Execution sequence} may be determined by a
processor that is applied after every program unit is translated and
before the program units are linked together into a program, or by the
processor that links the program units into a program. The processor may
cause all initializers to be executed before the main program is
executed. Processors for languages other than Fortran that provide for
the equivalent of module initializers, including Ada and Modula-2, have
used these and other strategies.
Alternatively, the need to execute an initializer may be determined
dynamically as the program executes. In this case, it would be necessary
for each initializer to determine whether it had been executed, so as not
to be executed more than once. If an initializer has been executed,
every initializer upon which it depends by use or host association has
also been executed, so it is not necessary to proceed from one
initializer to initializers for modules upon which it depends if it has
been executed.
\section{For the record, for submodule initializers\dots}
If submodule initializers are ever done, they should be restricted so as
to inhibit their ability to subvert the ancestor module's private data.
Sufficient restrictions are (1) a variable that is accessed by use
association, directly or indirectly, shall not appear in a variable
definition context, and (2) a procedure invoked by an initializer or
initializer procedure shall be an initializer procedure; it shall not
have a dummy procedure, and shall observe these restrictions.
\label{lastpage}
\end{document}