-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathapp3.tex
201 lines (194 loc) · 8.39 KB
/
app3.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
%\appendix
\section{Appendix: The Initial Static Basis}
\label{init-stat-bas-app}
\insertion{\thelibrary}{
In this appendix (and the next) we define a minimal initial basis for
execution. Richer bases may be provided by libraries.}
\insertion{\thelibrary}{
We\index{73.1} shall indicate components of the initial basis by the subscript 0.
The initial static basis is
$\B_0 = \T_0,\F_0,\G_0,\E_0$,
where $F_0 = \emptymap$, $\G_0 = \emptymap$ and
$$\T_0\ =\ \{\BOOL,\INT,\REAL,\STRING,\CHAR,\WORD,\LIST,\REF,\EXCN\}$$
The members of $\T_0$ are type names, not type constructors; for convenience
we have used type-constructor identifiers
to stand also for the type names which are bound to them in the initial
static type environment $\TE_0$. Of these type names,
~\LIST~ and ~\REF~
have arity 1, the rest have arity 0;
all except $\EXCN$ \insertion{\thelibrary}{and $\REAL$} admit equality.
Finally, $\E_0 = (\SE_0,\TE_0,\VE_0)$, where $\SE_0 = \emptymap$,
while $\TE_0$ and $\VE_0$ are shown in Figures~\ref{stat-te} and \ref{stat-ve},
respectively.
}
\deletion{\thelibrary}{
We\index{73.1} shall indicate components of the initial basis by the subscript 0.
The initial static basis is
\[ \B_0\ =\ (\M_0,\T_0),\F_0,\G_0,\E_0\]
where
\begin{itemize}
\item $\M_0\ =\ \emptyset$
\item $\T_0\ =\ \{\BOOL,\INT,\REAL,\STRING,\LIST,\REF,\EXCN,\INSTREAM,\OUTSTREAM\}$
\item $\F_0\ =\ \emptymap$
\item $\G_0\ =\ \emptymap$
\item $\E_0\ =\ \longE{0}$
\end{itemize}
The members of $\T_0$ are type names, not type constructors; for convenience
we have used type-constructor identifiers
to stand also for the type names which are bound to them in the initial
static type environment $\TE_0$. Of these type names,
~\LIST~ and ~\REF~
have arity 1, the rest have arity 0;
all except \EXCN, \INSTREAM~
and ~\OUTSTREAM~ admit equality.
The components of $\E_0$ are as follows:
\begin{itemize}
\item $\SE_0\ =\ \emptymap$
\item $\VE_0$ is shown in Figures~\ref{stat-ve} and \ref{stat-veio}.
Note that
$\Dom\VE_0$ contains those identifiers
({\tt true}, {\tt false}, {\tt nil},
\verb+::+, {\tt ref}) which are basic value constructors,
for reasons discussed in Section~\ref{stat-proj}.
$\VE_0$ also includes $\EE_0$, for the same reasons.
\item $\TE_0$ is shown in Figure~\ref{stat-te}. Note that the type
structures in $\TE_0$ contain the type schemes of all basic value
constructors.
\item $\Dom\EE_0\ =\ \BasExc$~, the set of basic exception names listed in
Section~\ref{bas-exc}.
In each case the associated type is ~\EXCN~, except that
~$\EE_0({\tt Io})=\STRING\rightarrow\EXCN$.
\end{itemize}
}
\deletion{\thelibrary}{
\begin{figure}
\begin{center}
\begin{tabular}{|rl|}
\hline
$\var$ & $\mapsto\ \tych$\\
\hline
{\tt std\_in} & $\mapsto\ \INSTREAM$\\
{\tt open\_in} & $\mapsto\ \STRING\to\INSTREAM$\\
{\tt input} & $\mapsto\ \INSTREAM\ \ast\ \INT\to\STRING$\\
{\tt lookahead} & $\mapsto\ \INSTREAM\to\STRING$\\
{\tt close\_in} & $\mapsto\ \INSTREAM\to\UNIT$\\
{\tt end\_of\_stream}
& $\mapsto\ \INSTREAM\to\BOOL$\\
\multicolumn{2}{|c|}{}\\
{\tt std\_out} & $\mapsto\ \OUTSTREAM$\\
{\tt open\_out} & $\mapsto\ \STRING\to\OUTSTREAM$\\
{\tt output} & $\mapsto\ \OUTSTREAM\ \ast\ \STRING\to\UNIT$\\
{\tt close\_out} & $\mapsto\ \OUTSTREAM\to\UNIT$\\
\hline
\end{tabular}
\end{center}
\vspace{3pt}
\caption{Static $\VE_0$ (Input/Output)\index{75.1}}
\label{stat-veio}
\end{figure}}
% \begin{figure}
% \begin{center}
% \begin{tabular}{|rll|}
% \hline
% $\tycon$ & $\mapsto\ \{\ \typefcn$, & $\{\con_1\mapsto\tych_1,\ldots,\con_n\mapsto\tych_n\}\ \}\quad (n\geq0)$\\
% \hline
% \UNIT & $\mapsto\ \{\ \Lambda().\{ \}$,
% & $\emptymap\ \}$ \\
% \BOOL & $\mapsto\ \{\ \BOOL$, & $\{\TRUE\mapsto\BOOL,
% \ \FALSE\mapsto\BOOL\}\ \}$\\
% \INT & $\mapsto\ \{\ \INT$, & $\{\}\ \}$\\
% \REAL & $\mapsto\ \{\ \REAL$, & $\{\}\ \}$\\
% \STRING & $\mapsto\ \{\ \STRING$, & $\{\}\ \}$\\
% \LIST & $\mapsto\ \{\ \LIST$, & $\{\NIL\mapsto\forall\atyvar\ .\ \atyvar\ \LIST$,\\
% & & \ml{::}$\mapsto\forall\atyvar\ .
% \ \atyvar\ast\atyvar\ \LIST
% \to\atyvar\ \LIST\}\ \}$\\
% %\LIST & \multicolumn{2}{l|}{$\mapsto\ \{\ \LIST, \{\NIL\mapsto
% % \forall\alpha.\alpha\LIST,\
% % \ml{::}\mapsto\forall\alpha.
% % \alpha\ast\alpha\LIST
% % \to\alpha\LIST\}\ \}$
% % }\\
% \REF & $\mapsto\ \{\ \REF$, & \ adhocreplacementl{\thenoimptypes}{6cm}{$\{\REF\mapsto\forall\ \aityvar\ .\
% \aityvar\to\aityvar\ \REF\}\ \}$}{$\{\REF\mapsto\forall\ \atyvar\ .\
% \atyvar\to\atyvar\ \REF\}\ \}$}\\
% \EXCN & $\mapsto\ \{\ \EXCN$, & $\emptymap\ \}$\\
% \INSTREAM & $\mapsto\ \{\ \INSTREAM$,& $\emptymap\ \}$ \\
% \OUTSTREAM & $\mapsto\ \{\ \OUTSTREAM$,& $\emptymap\ \}$ \\
% \hline
% \end{tabular}
% \end{center}
% \caption{Static $\TE_0$\index{75.2}}
% \label{stat-te}
% \end{figure}
\vskip-5mm
\insertion{\thelibrary}{
\begin{figure}[h]
\begin{center}
\begin{tabular}{|rll|}
\hline
$\tycon$ & $\mapsto\ (\ \typefcn$, & $\{\vid_1\mapsto(\tych_1,\is_1),\ldots,\vid_n\mapsto(\tych_n,\is_n)\}\ )\quad (n\geq0)$\\
\hline
\UNIT & $\mapsto\ (\ \Lambda().\{ \}$,
& $\emptymap\ )$ \\
\BOOL & $\mapsto\ (\ \BOOL$, & $\{\TRUE\mapsto(\BOOL,\isc),
\ \FALSE\mapsto(\BOOL,\isc)\}\ )$\\
\INT & $\mapsto\ (\ \INT$, & $\{\}\ )$\\
\WORD & $\mapsto\ (\ \WORD$, & $\{\}\ )$\\
\REAL & $\mapsto\ (\ \REAL$, & $\{\}\ )$\\
\STRING & $\mapsto\ (\ \STRING$, & $\{\}\ )$\\
%\UNISTRING & $\mapsto\ (\ \UNISTRING$, & $\{\}\ )$\\
\CHAR & $\mapsto\ (\ \CHAR$, & $\{\}\ )$\\
%\UNICHAR & $\mapsto\ (\ \UNICHAR$, & $\{\}\ )$\\
\LIST & $\mapsto\ (\ \LIST$, & $\{\NIL\mapsto(\forall\atyvar\ .\ \atyvar\ \LIST, \isc)$,\\
& & \ml{::}$\mapsto(\forall\atyvar\ .
\ \atyvar\ast\atyvar\ \LIST
\to\atyvar\ \LIST, \isc)\}\ )$\\
\REF & $\mapsto\ (\ \REF$, & $\{\REF\mapsto(\forall\ \atyvar\ .\
\atyvar\to\atyvar\ \REF,\isc)\}\ )$\\
\EXCN & $\mapsto\ (\ \EXCN$, & $\emptymap\ )$\\
\hline
\end{tabular}
\end{center}
\vskip-3mm
\caption{Static $\TE_0$\index{75.2}}
\vskip-3mm
\label{stat-te}
\end{figure}}
\note{\thelibrary}{Figure (Static $VE_0$): many entries removed (now in library/basis)}
\insertion{\thelibrary}{\begin{figure}[h]
\begin{tabular}{|rl|rl|}
\multicolumn{2}{c}{NONFIX}& \multicolumn{2}{c}{INFIX}\\
\hline
$\vid$ & $\mapsto\ (\tych,\is)$
& $\vid$ & $\mapsto\ (\tych,\is)$\\
\hline
\REF & $\mapsto\ (\forall\ \atyvar\ .\ \atyvar\to\atyvar\ \REF$, \isc)
& \multicolumn{2}{l|}{Precedence 5, right associative :} \\
{\tt nil} & $\mapsto\ (\forall\atyvar.\ \atyvar\ \LIST$, \isc)
& \boxml{::} & $\mapsto\ (\forall\atyvar.
\atyvar\;{\ast}\;\atyvar\;\LIST
\to\atyvar\;\LIST$, \isc)\\
{\tt true} & $\mapsto\ (\BOOL,\isc)$
& \multicolumn{2}{l|}{Precedence 4, left associative :}\\
{\tt false} & $\mapsto\ (\BOOL,\isc)$
& \boxml{=} & $\mapsto\ (\forall\aetyvar.\
\aetyvar\ \ast\ \aetyvar\to\BOOL, \isv)$\\
{\tt Match} & $\mapsto\ (\EXCN,\ise)$
& \multicolumn{2}{l|}{Precedence 3, left associative :} \\
{\tt Bind} & $\mapsto\ (\EXCN, \ise)$
& \boxml{:=} & $\mapsto\ (\forall\atyvar.\
\atyvar\ \REF\ \ast\ \atyvar\to\{\}, \isv)$\\
\hline
\end{tabular}
\vspace{3pt}
Note:
In type schemes we have taken the liberty of writing
$\ty_1\ast\ty_2$ in place of
$\{\mbox{\tt 1}\mapsto\ty_1,\mbox{\tt 2}\mapsto\ty_2\}$.
\vskip-4mm
\caption{Static $\VE_0$\index{74}}
\vskip-2mm
\label{stat-ve}
\end{figure}
}