-
Notifications
You must be signed in to change notification settings - Fork 13
/
changes.tex
4782 lines (4203 loc) · 163 KB
/
changes.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%
\notePage{0}{Title and list of authors changed}
%
\notePage{iii}{Prelude added.}
%
\replacementPage{iv}{fourteen}{twenty}
%
\deletionPage{vii}{
The Definition has evolved through a sequence of three previous versions,
circulated as Technical Reports. For those who have followed the
sequence, we should point out that the treatment of {\sl equality types}
and of {\sl admissibility} has been slightly modified in this publication
to meet the claim for principal signatures. The changes are mainly
in Sections~4.9, 5.5 and 5.13 and in the inference rules~19, 20,
29 and 65.}
%
\replacementPage{vii}{Some}{Many}
%
\replacementPage{vii}{have also become}{became}
%
\insertionPage{vii}{1990}
%
\replacementPage{vii}{will not be}{are not}
%
\replacementPage{vii}{So we are writing
a Commentary\cite{mt91} on the Definition which will assist people in reading it, and
which will serve as a bridge between the Definition and other texts.}
{We therefore wrote a
Commentary on the 1990
Definition to
assist people in reading it, and to
serve as a bridge between the Definition and other texts. Though in
part outdated by the present revision, the Commentary still fulfils its
purpose.}
%
\insertionPage{vii}{There exist several textbooks on programming
with Standard ML\cite{paulson96,mcp93,Ullman94,stansifer92}. The second
edition of Pauson's book\cite{paulson96} conforms with the present revision.}
%
\deletionPage{vii}{\begin{flushright} Edinburgh\\August 1989 \end{flushright}}
%
\replacementPage{1}{just}{part of}
%
\replacementPage{2}{all predefined identifiers.}{a
small set of predefined identifiers. A richer basis is defined
in a separate document\cite{mllib96}.}
%
\deletionPage{2}{
This theory, particularly the theory of types and signatures, will
benefit from a more pedagogic treatment in other publications; the
treatment here is
probably the minimum required to understand the meaning of the rules.}
%
\deletionPage{2}{In two cases, however, they are presented as ``claims'' rather than
theorems; these are the claim of principal environments in
Section~\ref{principal-env-sec}, and the claim of principal signatures
in Section~\ref{prinsig-sec}. We need further confirmation of our
detailed proofs of these claims, before asserting them as theorems.}
%
\replacementPage{3}{
An\index{6.2} {\sl integer constant}
is any non-empty sequence of digits, possibly preceded
by a negation symbol (\tttilde).
A {\sl real constant} is an integer constant,
possibly followed by a point ({\tt .}) and one or
more digits, possibly followed by an exponent symbol ~{\tt E}~ and an integer
constant; at least one of the optional parts must occur, hence no integer
constant is a real constant.}{
An\index{6.2} {\sl integer constant (in
decimal notation)} is an optional negation symbol (\tttilde)
followed by a non-empty sequence of decimal digits (\boxml{0}-\boxml{9}).
An {\sl integer constant (in
hexadecimal notation)} is an optional negation symbol
followed by \boxml{0x} followed by a non-empty sequence of
hexadecimal digits (\boxml{0}-\boxml{9}\boxml{a}-\boxml{f}\boxml{A}-\boxml{F},
where \boxml{A}-\boxml{F} are alternatives for \boxml{a}-\boxml{f},
respectively).
A {\sl word constant (in decimal notation)} is \boxml{0w} followed
by a non-empty sequence of decimal digits. A {\sl word constant
(in hexadecimal notation)} is \boxml{0wx} followed by a non-empty
sequence of hexadecimal digits.
A {\sl real constant} is an integer constant in decimal notation,
possibly followed by a point ({\tt .}) and one or
more decimal digits, possibly followed by an exponent symbol ~({\tt E} or {\tt e})~ and an integer
constant in decimal notation; at least one of the optional parts must occur, hence no integer
constant is a real constant.}
%
\replacementPage{3}{We assume an underlying alphabet of 256 characters
(numbered 0 to 255) such that the characters with numbers
0 to 127 coincide with the ASCII character set.
}{We assume an underlying alphabet of $N$ characters ($N \geq 256$), numbered
$0$ to $N-1$, which agrees with the ASCII character set on the characters
numbered 0 to 127. The interval $[0, N-1]$ is called the {\sl ordinal range} of
the alphabet.
%For use in string and character constants, we assume two underlying
%alphabets, of 8 bit and 16 bit characters, respectively. The {\sl ordinal
%ranges} of the two alphabets are $[0,255]$ and $[0,65535]$, respectively.
%In both cases, the characters with numbers 0 to 127 are assumed to coincide
%with the ASCII character set.
}
%
\notePage{3}{Inserted additional escape sequences in figure concerning
string constants and unicodes}
%
\insertionPage{4}{A {\sl character constant} is a sequence of the form
{\tt\#}$s$, where $s$ is a string constant denoting a string of size one character.
Libraries may provide multiple numeric types and multiple string types.
To each string type
corresponds an alphabet with ordinal range $[0, N-1]$
for some $N\geq 256$; each alphabet must agree with the ASCII character set on
the characters numbered 0 to 127. When multiple alphabets are supported,
all characters of a given string constant are interpreted over the same
alphabet. For each special constant, overloading
resolution is used for determining the type of the constant
(see Appendix~\ref{overload.sec}).
% All the escape sequences in a given string constant are interpreted
% over the same underlying alphabet (either 8-bit characters or 16-bit
% characters), and for each string constant this alphabet is determined
% by overloading resolution (see Appendix~\ref{overload.sec}).
% It is a compile-time error
% if the
%constant contains an escape sequence of the form $\uconst$ where
%$xxxx$ denotes an integer outside the ordinal range of the alphabet so
%determined. For example, within a sequence of 8-bit characters, the
%two leftmost hexadecimal digits of $\uconst$ must be {\tt 0} (zero).
}
%
\insertionPage{4}{word, character}
%
\replacementPage{4}{An
unmatched comment bracket should be
detected by the compiler.}{No space is allowed between
the two characters which make up
a comment bracket \ml{(*} or \ml{*)}. An unmatched
\boxml{(*} should be detected by the compiler.}
%
\notePage{4}{Figure 1 replaced by new figure (Var, Con and ExCon
merged into VId)}
%
\replacementPage{4}{$\var$}{$\vid$}
%
\replacementPage{4}{Var}{$\VId$}
%
\deletionPage{5}{The subclass $\ImpTyVar$ of
$\TyVar$, the {\sl imperative} type variables, consists of those which
start with one or two primes followed by an underbar. The complement
$\AppTyVar=\TyVar\setminus\ImpTyVar$\index{8.1} consists of the {\sl
applicative} type variables.
}
%
\replacementPage{5}{The other six classes ({\Var}, {\Con},
{\Exn}, {\TyCon}, {\Lab} and {\StrId}) are represented by identifiers
not starting with a prime.}{The other four classes ({\VId},
{\TyCon}, {\Lab} and {\StrId}) are represented by identifiers
not starting with a prime.}
%
\replacementPage{5}{six}{four}
%
\replacementPage{5}{
\item Elsewhere, $\id$ is an exception constructor if it occurs in
the scope of an exception binding which introduces it as such,
or a value constructor if it occurs in the
scope of a datatype binding which introduced it as such;
otherwise it is a value variable.}{
\item Elsewhere, $\id$ is a value identifier.}
%
\deletionPage{5}{
It follows from the last rule that no value declaration can make a
``hole'' in the scope of a value or exception constructor
by introducing the same identifier as a variable; this
is because, in the scope of the declaration which introduces $\id$ as a value
or exception constructor, any occurrence of $\id$ in a pattern
is interpreted as the
constructor and not as the binding occurrence of a new variable.}
%
\replacementPage{6}{$\var$, a
$\con$ or an $\exn$}{$\vid$}
%
\replacementPage{6}{directive.}{directive, and in these uses it is called an
{\sl infixed operator}.}
%
\replacementPage{6}{$\id$}{$\vid$}
%
\replacementPage{6}{``$\exp_1\ \id\ \exp_2$''}{``$\exp_1\ \vid\ \exp_2$''}
%
\replacementPage{6}{``$\pat_1\
\id\ \pat_2$''}{``$\pat_1\
\vid\ \pat_2$''}
%
\replacementPage{6}{$\id$}{$\vid$}
%
\replacementPage{6}{$\id$}{$\vid$}
%
\replacementPage{6}{$\id$}{$\vid$}
%
\replacementPage{6}{$\id$}{$\vid$}
%
\replacementPage{6}{\[ \longinfix \]
\[ \longinfixr \]
\[ \longnonfix \]}{\[ \newlonginfix \]
\[ \newlonginfixr \]
\[ \newlongnonfix \]}
%
\replacementPage{6}{$0$}{{\tt 0}}
%
\replacementPage{6}{~$\INFIX$~ and ~$\INFIXR$~ dictate left and right
associativity respectively; association is always to the left for different
operators of the same precedence.}{~$\INFIX$~ and ~$\INFIXR$~ dictate left and right
associativity respectively. In an expression of the form $\exp_1\, \vid_1\, \exp_2\, \vid_2\, \exp_3$, where
$\vid_1$ and $\vid_2$ are infixed operators with the same precedence,
either both must associate to the left or both must
associate to the right.
For example, suppose that {\tt <<} and {\tt >>} have equal precedence,
but associate to the left and right respectively; then
\medskip
\tabskip4cm
\halign to\hsize{\indent\hfil{\tt #}\tabskip1em&\hfil#\hfil\ &\ {\tt #}\hfil\cr
x << y << z&parses as&(x << y) << z\cr
x >> y >> z&parses as&x >> (y >> z)\cr
x << y >> z&is illegal\cr
x >> y << z&is illegal\cr}
\medskip}
%
\replacementPage{6}{infix}{infixed}
%
\replacementPage{7}{Figures~\ref{exp-syn}
and~\ref{pat-syn}.}{Figures~\ref{pat-syn} and~\ref{exp-syn}.}
%
\deletionPage{8}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
& & \opp\var & variable\cr
& & \opp\longcon & constant\cr
& & \opp\longexn & exception constant\cr}\end{minipage}}
%
\insertionPage{8}{$\opp\longvid$\qquad value identifier}
%
\insertionPage{8}{::=}
%
\deletionPage{8}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
& & \opp\conpat & value construction\cr
& & \opp\exconpat & exception construction\cr
& & \infpat & infixed value construction\cr
& & \infexpat & infixed exception construction\cr}\end{minipage}}
%
\insertionPage{8}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
& \opp\vidpat & constructed pattern\cr
& & \vidinfpat & infixed value construction\cr}\end{minipage}}
%
\replacementPage{8}{$\opp\layeredpat$}{$\opp\layeredvidpat$}
%
\deletionPage{10}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
& & \opp\longvar & value variable\cr
& & \opp\longcon & value constructor\cr
& & \opp\longexn & exception constructor\cr}\end{minipage}}
%
\insertionPage{10}{$\opp\longvid$\quad value identifier}
%
\replacementPage{10}{\infexp}{\vidinfexp}
%
\replacementPage{10}{\valdec}{\explicitvaldec}
%
\insertionPage{10}{$\datatyperepldecb$\qquad datatype replication}
%
\replacementPage{10}{\longinfix}{\newlonginfix}
%
\replacementPage{10}{\longinfixr}{\newlonginfixr}
%
\replacementPage{10}{\longnonfix}{\newlongnonfix}
%
\replacementPage{10}{$\opp\longconstrs$}{$\opp\longvidconstrs$}
%
\replacementPage{10}{\generativeexnbind}{\generativeexnvidbind}
%
\replacementPage{10}{\eqexnbind}{\eqexnvidbind}
%
\deletionPage{8}{No pattern may contain the same $\var$ twice. }
%
\insertionPage{8}{-expression}
%
\replacementPage{8}{constructors}{identifiers}
%
\insertionPage{8}{
For each $\dec$ of the form $\datatyperepldeca$,
the sequences $\tyvarseq$ and $\tyvarseq'$ must be equal and neither
may contain the same type variable twice.}
%
\insertionPage{9}{\item No $\datbind$ or $\exnbind$ may bind $\TRUE$, $\FALSE$, $\IT$,
$\NIL$, \boxml{::} or $\REF$.}
%
\replacementPage{11}{The derived forms for modules concern functors and appear in
Appendix~\ref{derived-forms-app}.}{The derived forms for modules appear in
Appendix~\ref{derived-forms-app}.}
%
\notePage{11}{Inserted new keywords {\tt where} and {\tt :>}}
%
\replacementPage{11}{syntax}{identifier}
%
\replacementPage{11}{generative}{basic}
%
\deletionPage{11}{A more liberal scheme (which is under consideration)
would allow fixity directives to appear also as specifications, so that
fixity may be dictated by a signature expression; furthermore, it would allow an ~$\OPEN$~
or ~$\INCLUDE$~ construction to restore the fixity which prevailed
in the structures being opened, or in the signatures being included.
This scheme is not adopted at present.}
%
\deletionPage{12}{SharEq \quad sharing equations}
%
\deletionPage{12}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
FunSigExp & functor signature expressions\cr
FunSpec & functor specifications\cr
FunDesc & functor descriptions\cr}\end{minipage}}
%
\deletionPage{11}{It should be noted that functor specifications (FunSpec) cannot
occur in programs;
neither can the associated functor descriptions (FunDesc)
and functor signature expressions (FunSigExp). The purpose of a $\funspec$
is to specify the static attributes (i.e. functor signature) of one
or more functors. This will be useful, in fact essential, for
separate compilation of functors. If, for example, a functor $g$
refers to another functor $f$ then --- in order to compile $g$ in
the absence of the declaration of $f$ --- at least the specification
of $f$ (i.e. its functor signature) must be available. At present there is no
special grammatical form for a separately compilable ``chunk'' of text
-- which we may like to call call a {\sl module} -- containing a $\fundec$
together with a $\funspec$ specifying its global references. However, below in
the semantics for Modules it is defined when a
declared functor matches a functor signature specified for it. This determines
exactly those functor environments (containing declared functors
such as $f$) into which the separately compiled ``chunk''
containing the declaration of $g$ may be loaded.}
%
\replacementPage{13}{generative}{basic}
%
\insertionPage{13}{$\transpconstraint$\quad transparent constraint}
%
\insertionPage{13}{ $ \opaqueconstraint$\quad opaque constraint}
%
\replacementPage{13}{$\strbindera$}{$\barestrbindera$}
%
\replacementPage{13}{generative}{basic}
%
\insertionPage{13}{$\wheretypesigexp$\quad type realisation}
%
\deletionPage{13}{single}
%
\deletionPage{13}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
& & \emptysigdec & empty\cr
& & \seqsigdec & sequential\cr}\end{minipage}}
%
\replacementPage{12}{, $\strdesc$ or $\fundesc$}{or $\strdesc$}
%
\replacementPage{12}{constructors}{identifiers}
%
\insertionPage{12}{
No ${\it tyvarseq}$ may contain the same ${\it tyvar}$ twice.}
%
\insertionPage{12}{
For each $\spec$ of the form $\datatypereplspeca$, the sequences
$\tyvarseq$ and $\tyvarseq'$ must be equal.}
%
\insertionPage{12}{
Any $\tyvar$ occurring on the right side of a $\datdesc$ of the form\linebreak
$\tyvarseq \;\tycon\;\boxml{=}$ $\cdots$ must occur
in the $\tyvarseq$; similarly, in signature expressions of the form $\sigexp\ \boxml{where type}\, \tyvarseq\,\longtycon\,$
$\boxml{=}\,\ty$, any $\tyvar$ occurring in $\ty$ must occur in $\tyvarseq$.}
%
\insertionPage{12}{\item No $\datdesc$ or $\exndesc$ may describe
$\TRUE$, $\FALSE$, $\IT$,
$\NIL$, \boxml{::} or $\REF$.}
%
\insertionPage{14}{$\datatypereplspecb$\qquad replication}
%
\deletionPage{14}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
& & \sharingspec & sharing\cr
& & \localspec & local\cr
& & \openspec & open ($n\geq 1$)\cr }\end{minipage}}
%
\replacementPage{14}{$\inclspec$\qquad include ($n\geq 1$)}{
$\singleinclspec$\qquad include}
%
\insertionPage{14}{$\newsharingspec$\qquad sharing \quad $(n\geq 2)$}
%
\replacementPage{14}{\valdescription}{\valviddescription}
%
\replacementPage{14}{\condescription}{\conviddescription}
%
\replacementPage{14}{\exndescription}{\exnviddescription}
%
\deletionPage{14}{\begin{minipage}{\textwidth}\halign{\indent#\hfil&#\hfil&#\hfil&#\hfil\cr
\shareq & ::= & \strshareq & structure sharing\cr
& & & \qquad ($n\geq 2$) \cr
& & \typshareq & type sharing \cr
& & & \qquad ($n\geq 2$) \cr
& & \multshareq & multiple\cr\noalign{\vspace{6pt}}
\noalign{\vspace{6pt}}}\end{minipage}}
%
\notePage{12}{Figure 8: Functor signature expressions and
functor specifications have been removed. Sequential and empty
functor declarations and signature declarations have been removed.
The grammar for $\topdec$ now allows sequencing (without semicolon)
of structure-level declarations, signature declarations and functor
declarations.}
%
\deletionPage{12}{
\subsection{Closure Restrictions}
\label{closure-restr-sec}
The\index{18.2} semantics presented in later sections requires no restriction on
reference to non-local identifiers. For example, it allows a signature
expression to refer to external signature identifiers and
(via ~$\SHARING$~ or ~$\OPEN$~) to external structure identifiers; it also
allows a functor to refer to external identifiers of any kind.
However, implementers who want to provide a simple facility for
separate compilation may want to impose the following restrictions
(ignoring references to identifiers bound in the initial basis
$\B_0$, which may occur anywhere):
%However, in the present version of the language,
%apart from references to identifiers bound in the initial basis $B_0$
%(which may occur anywhere), it is required that signatures only refer
%non-locally to signature identifiers and that functors only
%refer non-locally to functor and signature identifiers.
%These restrictions ease separate
%compilation; however, they may be relaxed in a future version of the language.
%
%More precisely, the restrictions are as follows (ignoring reference to
%identifiers bound in $B_0$):
\begin{enumerate}
\item In any signature binding ~$\sigid\ \mbox{{\tt =}}\ \sigexp$~,
the only non-local
references in $\sigexp$ are to signature identifiers.
\item In any functor description ~$\funid\ \longfunsigexpa$~,
the only non-local
references in $\sigexp$ and $\sigexp'$ are to signature identifiers,
except that $\sigexp'$ may refer to $\strid$ and its components.
\item In any functor binding ~$\funstrbinder$~, the only non-local
references in $\sigexp$, $\sigexp'$ and $\strexp$ are to functor and signature
identifiers,
except that both $\sigexp'$ and $\strexp$ may refer to $\strid$ and
its components.
\end{enumerate}
In the last two cases the final qualification allows, for example, sharing
constraints to be specified between functor argument and result.
(For a completely precise definition of these closure restrictions,
see the comments to rules \ref{single-sigdec-rule}
(page~\pageref{single-sigdec-rule}),
\ref{singfunspec-rule} (page~\pageref{singfunspec-rule})
and \ref{singfundec-rule} (page~\pageref{singfundec-rule})
in the static semantics of modules, Section~\ref{statmod-sec}.)
The\index{19.1}
significance of these restrictions is that they may ease separate
compilation; this may be seen as follows. If one takes a {\sl module}
to be a sequence of signature declarations, functor specifications
and functor declarations satisfying the above restrictions then the
elaboration of a module can be made to depend on the initial
static basis alone (in particular, it will not rely on
structures outside the module). Moreover, the elaboration
of a module cannot create new free structure or type names, so
name consistency (as defined in Section~\ref{consistency-sec},
page \pageref{consistency-sec}) is automatically preserved
across separately compiled modules. On the other hand,
imposing these restrictions may force the programmer to write
many more sharing equations than is needed if functors
and signature expressions can refer to free structures.
}
%
\replacementPage{15}{All semantic objects in the static semantics of the entire
language are built from identifiers and two further kinds of simple objects:
type constructor names and structure names.}{All semantic objects in
the static semantics of the entire
language are built from identifiers and two further kinds of simple objects:
type constructor names and identifier status descriptors.}
%
\deletionPage{15}{Structure names play an active role only in
the Modules semantics; they enter the Core semantics only because
they appear in structure environments, which (in turn) are needed in the Core
semantics only to determine the values of long identifiers.}
%
\replacementPage{15}{
\begin{displaymath}
\begin{array}{rclr}
\alpha\ {\rm or}\ \tyvar & \in & \TyVar & \mbox{type variables}\\
\t & \in & \TyNames & \mbox{type names}\\
\m & \in & \StrNames & \mbox{structure names}
\end{array}
\end{displaymath}}{\begin{displaymath}
\begin{array}{rcll}
\alpha\ {\rm or}\ \tyvar & \in & \TyVar & \mbox{type variables}\\
\t & \in & \TyNames & \mbox{type names}\\
\is & \in & \IdStatus = \{\isc,\ise,\isv\} & \mbox{identifier status descriptors}
\end{array}
\end{displaymath}}
%
\deletionPage{15}{Independently hereof, each $\alpha$ possesses a boolean attribute,
the {\sl imperative} attribute, which determines whether it is imperative,
i.e. whether it is a member of $\ImpTyVar$ (defined on page~\pageref{etyvar-lab})
or not.}
%
\replacementPage{15}{{\INT}, {\REAL}
or {\STRING}}{{\INT}, {\REAL}, {\WORD}, {\CHAR}
or {\STRING}}
%
\insertionPage{15}{(However, see Appendix~\ref{overload.sec}
concerning types of overloaded special constants.)}
%
\replacementPage{16}{\RecType}{\RowType}
%
\replacementPage{16}{\RecType}{\RowType}
%
\deletionPage{16}{\begin{minipage}{\textwidth}\halign{\indent$#$\hfil&$#$\hfil&$#$\hfil&$#$\hfil\cr
\S\ {\rm or}\ (\m,\E)
& \in & \Str = \StrNames\times\Env \cr}\end{minipage}}
%
\replacementPage{16}{\CE}{\VE}
%
\replacementPage{16}{$\TyStr = \TypeFcn\times\ConEnv$}{$\TyStr = \TypeFcn\times\ValEnv$}
%
\replacementPage{16}{$\StrEnv = \finfun{\StrId}{\Str}$}{$\StrEnv = \finfun{\StrId}{\Env}$}
%
\deletionPage{16}{$\CE\quad \in\quad \ConEnv = \finfun{\Con}{\TypeScheme}$}
%
\replacementPage{16}{$\VarEnv = \finfun{(\Var\cup\Con\cup\Exn)}{\TypeScheme}$}{$\ValEnv = \finfun{\VId}{\TypeScheme\times\IdStatus}$}
%
\deletionPage{16}{$\EE \in \ExnEnv = \finfun{\Exn}{\Type}$}
%
\replacementPage{16}{$\longE{}$}{$\newlongE{}$}
%
\replacementPage{16}{$\Env = \StrEnv\times\TyEnv\times\VarEnv\times\ExnEnv$}{$\Env = \StrEnv\times\TyEnv\times\ValEnv$}
%
\deletionPage{16}{Moreover, $\imptyvars A$ and $\apptyvars A$ denote respectively the set
of imperative type variables and the set of applicative
type variables occurring free in $A$.}
%
\insertionPage{16}{\par Also note that a value environment maps
value identifiers to a pair of a type scheme and an identifier status.
If $\VE(\vid) = (\sigma,\is)$, we say that $\vid$ {\sl has status $\is$
in $\VE$}. An occurrence of a value identifier which is elaborated
in $\VE$ is referred to as a {\sl value variable}, a {\sl value constructor}
or an {\sl exception constructor}, depending on whether its status in $\VE$
is $\isv$, $\isc$ or $\ise$, respectively. }
%
\replacementPage{17}{variable-environment}{value-environment}
%
\replacementPage{17}{variable}{metavariable}
%
\replacementPage{17}{variable-environment}{value-environment}
%
\deletionPage{17}{ and ``$\of{\m}{\S}$'' means ``the structure name of $\S$''}
%
\replacementPage{17}{For instance $\C(\tycon)$ means
$(\of{\TE}{\C})\tycon$.
A particular case needs mention: $\C(\con)$ is taken to stand for
$(\of{\VE}{\C})\con$; similarly, $\C(\exn)$ is taken to stand for
$(\of{\VE}{\C})\exn$.
The type scheme of a value constructor is
held in $\VE$ as well as in $\TE$ (where it will be recorded within
a $\CE$); similarly, the type of an exception constructor is held in
$\VE$ as well as in $\EE$.
Thus the re-binding of a constructor of either kind is given proper
effect by accessing it in $\VE$, rather than in $\TE$ or in $\EE$.}{For
instance $\C(\tycon)$ means
$(\of{\TE}{\C})\tycon$ and $\C(\vid)$ means $(\of{\VE}{(\of{E}{\C})})(\vid)$.}
%
\replacementPage{17}{For instance if $\longcon = \strid_1.\cdots.\strid_k.\con$ then
$\E(\longcon)$ means
\[ (\of{\VE}
{(\of{\SE}
{\cdots(\of{\SE}
{(\of{\SE}{\E})\strid_1}
)\strid_2\cdots}
)\strid_k}
)\con.
\]
}{For instance if $\longvid = \strid_1.\cdots.\strid_k.\vid$ then
$\E(\longvid)$ means
\[ (\of{\VE}
{(\of{\SE}
{\cdots(\of{\SE}
{(\of{\SE}{\E})\strid_1}
)\strid_2\cdots}
)\strid_k}
)\vid.
\]
}
%
\replacementPage{17}{$(\emptymap,\emptymap,\VE,\emptymap)$.}{$(\emptymap,\emptymap,\VE)$.}
%
\replacementPage{17}{$\E+(\emptymap,\emptymap,\VE,\emptymap)$.}{$\E+(\emptymap,\emptymap,\VE)$.}
%
\deletionPage{17}{Similarly, the imperative attribute has no significance
in the bound variable of a type function.}
%
\deletionPage{18}{A type is {\sl imperative} if all type variables occurring in it are
imperative.}
%
\replacementPage{18}{if $\tau'=\tau\{\tauk/\alphak\}$ for some $\tauk$, where each member $\tau_i$
of $\tauk$ admits equality if $\alpha_i$ does,
%poly
and $\tau_i$ is imperative if $\alpha_i$ is imperative.}{if $\tau'=\tau\{\tauk/\alphak\}$ for some $\tauk$, where each member $\tau_i$
of $\tauk$ admits equality if $\alpha_i$ does.}
%
\deletionPage{18}{Similarly, the imperative attribute of a bound type variable of a
type scheme {\sl is} significant.}
%
\insertionPage{18}{Moreover, in a value declaration
{\tt val $\tyvarseq$ $\valbind$}, the sequence $\tyvarseq$ binds
type variables: a type variable occurs free in
{\tt val $\tyvarseq$ $\valbind$} iff it occurs free in $\valbind$
and is not in the sequence $\tyvarseq$.}
%
\deletionPage{18}{
In the modules, a description of a value, type, or datatype
may contain explicit type variables whose scope is that
description.}
%
\insertionPage{18}{explicit binding of type
variables at {\tt val} is optional, so}
%
\insertionPage{18}{free}
%
\replacementPage{18}{First, an occurrence of $\alpha$ in a value declaration $\valdec$ is said
to be {\sl unguarded} if the occurrence is not part of a smaller value
declaration within $\valbind$.}{First, a free occurrence of $\alpha$ in a value declaration
$\explicitvaldec$ is said
to be {\sl unguarded} if the occurrence is not part of a smaller value
declaration within $\valbind$.}
%
\replacementPage{18}{Then we say that $\alpha$ is {\sl scoped at}
a particular occurrence
$O$ of $\valdec$ in a program if}{Then we say that $\alpha$ is {\sl implicitly scoped at} a particular value declaration
{\tt val $\tyvarseq$ $\valbind$} in a program if}
%
\replacementPage{18}{occurrence $O$.}{given one.}
%
\deletionPage{18}{
Hence, associated with every occurrence of a value declaration there is
a set $\U$ of the explicit type variables that are implicitly
scoped at that
occurrence. One may think of each occurrence of $\VAL$ as being implicitly
decorated with such a set, for instance:
\vspace*{3mm}
\halign{\indent$#$&$#$&$#$\cr
\mbox{$\VAL_{\{\}}$ \ml{x = }}&\mbox{\ml{(}}&
\mbox{\ml{let $\VAL_{\{\mbox{\ml{'a}}\}}$ Id1:'a->'a = fn z=>z in Id1 Id1 end,}}\cr
& &\mbox{\ml{let $\VAL_{\{\mbox{\ml{'a}}\}}$ Id2:'a->'a = fn z=>z in Id2 Id2 end)}}\cr
\noalign{\vspace*{3mm}}
\mbox{$\VAL_{\{\mbox{\ml{'a}}\}}$ \ml{x = }}&\mbox{\ml{(}}&
\mbox{\ml{let $\VAL_{\{\}}$ Id:'a->'a = fn z=>z in Id Id end,}}\cr
& &\mbox{\ml{fn z=> z:'a)}}\cr}
}
%
\insertionPage{19}{Henceforth, we assume that for every
value declaration $\boxml{val}\,\tyvarseq\cdots$ occurring in the
program, every explicit type variable implicitly scoped at the {\tt val}
has been added to $\tyvarseq$. Thus for example, in the two declarations
\begin{tabbing}
\indent\=\tt val x = let val id:'a->'a = fn z=>z in id id end\\
\>\tt val x = (let val id:'a->'a = fn z=>z in id id end; fn z=>z:'a)
\end{tabbing}
the type variable \boxml{'a} is scoped differently; they become respectively
\begin{tabbing}
\indent\=\tt val x = let val 'a id:'a->'a = fn z=>z in id id end\\
\>\tt val 'a x = (let val id:'a->'a = fn z=>z in id id end; fn z=>z:'a)
\end{tabbing}
}
%
\replacementPage{19}{According}{Then, according}
%
\replacementPage{19}{\ml{Id}}{\ml{id}}
%
\replacementPage{19}{\ml{Id Id}}{\ml{id id}}
%
\deletionPage{19}{
\subsection{Non-expansive Expressions}
\label{expansive-sec}
In\index{23.4} order to treat polymorphic references and exceptions,
the set Exp of expressions is partitioned into two classes, the {\sl
expansive} and the {\sl non-expansive} expressions.
Any variable,
constructor and $\FN$ expression, possibly constrained by one or more
type expressions, is non-expansive; all other expressions are said to
be expansive. The idea is that the dynamic evaluation of a
non-expansive expression will neither generate an exception nor extend
the domain of the memory, while the evaluation of an expansive
expression might.}
%
\insertionPage{19}{
\subsection{Non-expansive Expressions}
\label{expansive-sec}
In\index{23.4} order to treat polymorphic references and exceptions,
the set Exp of expressions is partitioned into two classes, the {\sl
expansive} and the {\sl non-expansive} expressions.
An expression
is {\sl non-expansive in context $\C$} if, after replacing infixed forms
by their equivalent prefixed forms, and derived forms by their equivalent
forms, it can be generated by the following grammar from the
non-terminal $\nexp$:
\medskip
\halign{\indent\hfil$#$\ &\ $#$\hfil\ &\ $#$\hfil&\ #\hfil\cr
\nexp&::=&\scon\cr
&&\langle\OP\rangle\longvid\cr
&&\ttlbrace\langle\nexprow\rangle\ttrbrace\cr
&&\boxml{($\nexp$)}\cr
&&\boxml{$\conexp\;\nexp$}\cr
%&&\boxml{$\longvid\;\nexp$}\qquad\qquad\hbox{restrictions:}&$\longvid\neq\REF$ and\cr
%&&&$\of{\is}{\C(\longvid)}\in\{\isc,\ise\}$\cr
&&\nexp \boxml{:} \ty\cr
%&&\boxml{$\nexp$ handle $\match$}\cr
&&\boxml{fn $\match$}\cr%\cr
\nexprow&::=&\boxml{$\lab$ = $\nexp\langle$, $\nexprow\rangle$}\cr
\conexp&::=&\boxml{($\conexp\langle$:$\ty\rangle$)}\cr
&&\hbox{$\langle\OP\rangle\longvid$\hskip3cm Restriction:}&$\longvid\neq\REF$ and\cr
&&&$\of{\is}{\C(\longvid)}\in\{\isc,\ise\}$\cr}
\medskip
\noindent
All other expressions are said to be {\sl expansive (in $C$)}.
The idea is that the dynamic evaluation of a
non-expansive expression will neither generate an exception nor extend
the domain of the memory, while the evaluation of an expansive
expression might.
}
%
\replacementPage{19}{variable environment}{value
environment}
%
\replacementPage{19}{\[\cl{A}{\VE}=\{\id\mapsto\cl{A}{(\tau)}\ ;\ \VE(\id)=\tau\}\]}{\[\cl{A}{\VE}=\{\vid\mapsto(\cl{A}{(\tau)},\is)\ ;\ \VE(\vid)=(\tau,\is)\}\]}
%
\deletionPage{20}{with a similar definition for $\cl{A}{\CE}$.}
%
\replacementPage{20}{variable environment}{value environment}
%
\replacementPage{20}{Thus, for each $\var\in\Dom\VE$
there is a unique \mbox{\pat\ \ml{=} \exp}
in $\valbind$ which binds $\var$.}{Thus, for each $\vid\in\Dom\VE$
there is a unique \mbox{\pat\ \ml{=} \exp}
in $\valbind$ which binds $\vid$.}
%
\replacementPage{20}{$\VE(\var)=\tau$}{$\VE(\vid)=(\tau,\is)$}
%
\replacementPage{20}{$\cl{\C,\valbind}{\VE(\var)}=\longtych$}{$\cl{\C,\valbind}{\VE(\vid)}=(\longtych,\is)$}
%
\replacementPage{20}{\[\alphak=\cases{\TyVarFcn\tau\setminus\TyVarFcn\C,&if $\exp$
is non-expansive;\cr
\apptyvars\tau\setminus\TyVarFcn\C,&if $\exp$ is expansive.}
\]
}{
\[\alphak=\cases{\TyVarFcn\tau\setminus\TyVarFcn\C,&if $\exp$
is non-expansive in $\C$;\cr
(),&if $\exp$ is expansive in $\C$.}
\]}
%
\deletionPage{20}{Notice that the form of $\valbind$ does not affect the binding of
applicative type variables, only the binding of imperative
type variables.}
%
\replacementPage{20}{$(\theta,\CE)$}{$(\theta,\VE)$}
%
\replacementPage{20}{$(\theta,\CE)$}{$(\theta,\VE)$}
%
\replacementPage{20}{$\CE\neq\emptymap$}{$\VE\neq\emptymap$}
%
\insertionPage{20}{An object or assembly $A$ of semantic objects is {\sl well-formed} if every type structure
occurring in $A$ is well-formed.}
%
\replacementPage{20}{assumed}{required}
%
\replacementPage{20}{$(\t,\CE)$}{$(\t,\VE)$}
%
\replacementPage{20}{$\CE(\con)$}{$\VE(\vid)$}
%
\replacementPage{20}{$\forall\alphak.(\tau\rightarrow\alphak\t)$,}{$(\forall\alphak.(\tau\rightarrow\alphak\t), \is)$,}
%
\replacementPage{20}{$(\con,v)$}{$(\vid,v)$}
%
\replacementPage{20}{$(\t,\CE)$ }{$(\t,\VE)$ }
%
\replacementPage{20}{$\CE\neq\emptymap$}{$\VE\neq\emptymap$}
%
\replacementPage{20}{\[\TE=\{\tycon_i\mapsto(t_i,\CE_i)\ ;\ 1\leq i\leq k\},\]}{\[\TE=\{\tycon_i\mapsto(t_i,\VE_i)\ ;\ 1\leq i\leq k\},\]}
%
\replacementPage{20}{$\CE_i$}{$\VE_i$}
%
\replacementPage{20}{constructor}{value}
%
\replacementPage{20}{$\CE_i$}{$\VE_i$}
%
\replacementPage{21}{$\B=(\M,\T),\F,\G,\E$}{$\B=\T,\F,\G,\E$}
%
\replacementPage{21}{\begin{equation} % value variable
\label{varexp-rule}
\frac{\C(\longvar)\succ\tau}
{\C\ts\longvar\ra\tau}
\end{equation}}{\begin{equation} % value variable
\label{varexp-rule}
\frac{\C(\longvid) = (\sigma,\is)\qquad\sigma\succ\tau}
{\C\ts\longvid\ra\tau}
\end{equation}}
%
\deletionPage{21}{\begin{equation} % value constructor
\label{conexp-rule}
\frac{\C(\longcon)\succ\tau}
{\C\ts\longcon\ra\tau}
\end{equation}
\begin{equation} % exception constant
%\label{exconexp-rule}
\frac{\C(\longexn)=\tau}
{\C\ts\longexn\ra\tau}
\end{equation}}
%
\replacementPage{21}{\begin{equation} % local declaration
\label{let-rule}
\frac{\C\ts\dec\ra\E\qquad\C\oplus\E\ts\exp\ra\tau}
{\C\ts\letexp\ra\tau}\index{27.1}
\end{equation}}{\begin{equation} % local declaration
\label{let-rule}
\frac{\C\ts\dec\ra\E\qquad\C\oplus\E\ts\exp\ra\tau\qquad\TyNamesFcn\tau\subseteq\of{\T}{\C}}
{\C\ts\letexp\ra\tau}\index{27.1}
\end{equation}}