Skip to content

Commit 0acc413

Browse files
committed
Update pre-null-safety spec with null safety sections near the end of the spec
1 parent a0093ca commit 0acc413

File tree

2 files changed

+2997
-545
lines changed

2 files changed

+2997
-545
lines changed

specification/dart.sty

+117-24
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
\def\WITH{\keyword{with}}
6969
\def\YIELD{\keyword{yield}}
7070

71+
% Used for inline code snippets.
72+
\newcommand{\code}[1]{\texttt{#1}}
73+
7174
% Used to specify syntactic sugar.
7275
\def\LET{\keyword{let}}
7376
\newcommand{\Let}[3]{\code{\LET\,\,{#1}\,=\,{#2}\ \IN\ {#3}}}
@@ -78,8 +81,8 @@
7881
\newcommand{\LetMany}[5]{%
7982
\code{\LET\,\,{#1}\,=\,{#2},\ $\cdots$,\ {#3}\,=\,{#4}\ \IN\ {#5}}}
8083

81-
% Used for inline code snippets.
82-
\def\code#1{\texttt{#1}}
84+
% Used for inline meta-code snippets
85+
\newcommand{\metaCode}[1]{{\color{metaColor}\texttt{#1}}}
8386

8487
% `call` has no special lexical status, so we just use \code{}.
8588
\def\CALL{\code{call}}
@@ -112,17 +115,18 @@
112115
\definecolor{normativeColor}{rgb}{0,0,0}
113116
\definecolor{commentaryColor}{rgb}{0.5,0.5,0.5}
114117
\definecolor{rationaleColor}{rgb}{0.5,0.5,0.5}
118+
\definecolor{metaColor}{rgb}{0,0,1}
115119

116120
% Environments for different kinds of text.
117121
\newenvironment{Q}[1]{{\bf{}Upcoming: {#1}}}{}
118122
\newenvironment{rationale}[1]{{\color{rationaleColor}\it{#1}}}{}
119123
\newenvironment{commentary}[1]{{\color{commentaryColor}\sf{#1}}}{}
120124

121125
% Auxiliary functions.
122-
\newcommand{\flatten}[1]{\ensuremath{\mbox{\it flatten}({#1})}}
123-
\newcommand{\futureOrBase}[1]{\ensuremath{\mbox{\it futureOrBase}({#1})}}
124-
\newcommand{\overrides}[1]{\ensuremath{\mbox{\it overrides}({#1})}}
125-
\newcommand{\inherited}[1]{\ensuremath{\mbox{\it inherited}({#1})}}
126+
\newcommand{\flatten}[1]{\ensuremath{\metavar{flatten}({#1})}}
127+
\newcommand{\futureOrBase}[1]{\ensuremath{\metavar{futureOrBase}({#1})}}
128+
\newcommand{\overrides}[1]{\ensuremath{\metavar{overrides}({#1})}}
129+
\newcommand{\inherited}[1]{\ensuremath{\metavar{inherited}({#1})}}
126130

127131
% Used as a mini-section marker, indicating visibly that a range of
128132
% text (usually just a couple of paragraphs) are concerned with one
@@ -131,22 +135,30 @@
131135
\newcommand{\Case}[1]{\textbf{Case }$\langle\hspace{0.1em}${#1}$\hspace{0.1em}\rangle$\textbf{.}}
132136
\newcommand{\EndCase}{\mbox{}\hfill$\scriptscriptstyle\Box$\xspace}
133137

134-
\newenvironment{dartCode}[1][!ht] {%
138+
\newenvironment{dartCode}[1][!ht]{%
135139
\def\@programcr{\@addfield\strut}%
136140
\let\\=\@programcr%
137141
\relax\@vobeyspaces\obeylines%
138142
\ttfamily\color{commentaryColor}%
139143
\vspace{1em}%
140144
}{\normalcolor\vspace{1em}}
141145

142-
\newenvironment{normativeDartCode}[1][!ht] {%
146+
\newenvironment{normativeDartCode}[1][!ht]{%
143147
\def\@programcr{\@addfield\strut}%
144148
\let\\=\@programcr%
145149
\relax\@vobeyspaces\obeylines%
146150
\ttfamily\color{normativeColor}%
147151
\vspace{1em}%
148152
}{\normalcolor\vspace{1em}}
149153

154+
\newenvironment{metaLevelCode}[1][!ht]{%
155+
\def\@programcr{\@addfield\strut}%
156+
\let\\=\@programcr%
157+
\relax\@vobeyspaces\obeylines%
158+
\ttfamily\color{metaColor}%
159+
\vspace{1em}%
160+
}{\normalcolor\vspace{1em}}
161+
150162
% Used for comments in a code context.
151163
\def\comment#1{\textsf{#1}}
152164

@@ -156,7 +168,7 @@
156168

157169
% Used for defining occurrence of phrase, with customized index entry.
158170
\newcommand{\IndexCustom}[2]{%
159-
\leavevmode\marginpar{\ensuremath{\diamond}}\emph{#1}\index{#2}}
171+
\leavevmode\marginpar{\ensuremath{_{^\vartriangle}}}\emph{#1}\index{#2}}
160172

161173
% Used for the defining occurrence of a local symbol.
162174
\newcommand{\DefineSymbol}[1]{%
@@ -177,7 +189,11 @@
177189

178190
% Same appearance, but not adding an entry to the index.
179191
\newcommand{\NoIndex}[1]{%
180-
\leavevmode\marginpar{\quad\ensuremath{\diamond}}\emph{#1}}
192+
\leavevmode\marginpar{\ensuremath{_{^\vartriangle}}}\emph{#1}}
193+
194+
% Mark a compile-time error in the margin.
195+
\newcommand{\Error}[1]{%
196+
\leavevmode\marginpar{\ensuremath{_{^\ominus}}}{#1}}
181197

182198
% Used to specify comma separated lists of similar symbols.
183199
\newcommand{\List}[3]{\ensuremath{{#1}_{#2},\,\ldots,\ {#1}_{#3}}}
@@ -189,6 +205,22 @@
189205
\newcommand{\PairList}[4]{\ensuremath{%
190206
{#1}_{#3}\ {#2}_{#3},\,\ldots,\ {#1}_{#4}\ {#2}_{#4}}}
191207

208+
% Used to specify named arguments.
209+
% Parameters: Parameter name, argument name, index at start, index at end.
210+
\newcommand{\NamedArgumentList}[4]{\PairList{#1}{\!\!:\,\,{#2}}{#3}{#4}}
211+
212+
% Used to specify an argument list including positional and named arguments.
213+
% Parameters: Argument name, number of positional arguments, named parameter
214+
% name, number of named arguments.
215+
\newcommand{\ArgumentList}[4]{%
216+
\List{#1}{1}{#2},\ \NamedArgumentList{#3}{#1}{{#2}+1}{{#2}+{#4}}}
217+
218+
% Used to specify a standard argument list.
219+
\newcommand{\ArgumentListStd}{\ArgumentList{a}{n}{x}{k}}
220+
221+
% Used to specify a standard type argument list.
222+
\newcommand{\TypeArgumentListStd}{\List{A}{1}{r}}
223+
192224
% Used to specify a list of tuples of the form $(K_j, V_j)$ which are
193225
% used with collection literals.
194226
\newcommand{\KeyValueTypeList}[4]{\ensuremath{%
@@ -278,26 +310,28 @@
278310

279311
% Used to specify function type parameter lists with named optionals.
280312
% Arguments: Parameter type, number of required parameters,
281-
% name of optional parameters, number of optional parameters.
282-
\newcommand{\FunctionTypeNamedArguments}[4]{%
283-
\List{#1}{1}{#2},\ \{\PairList{#1}{#3}{{#2}+1}{{#2}+{#4}}\}}
313+
% name of optional parameters, number of optional parameters,
314+
% name of `required` symbol.
315+
\newcommand{\FunctionTypeNamedArguments}[5]{%
316+
\List{#1}{1}{#2},\ \{\TripleList{#5}{#1}{#3}{{#2}+1}{{#2}+{#4}}\}}
284317

285318
\newcommand{\FunctionTypeNamedArgumentsStd}{%
286-
\FunctionTypeNamedArguments{T}{n}{x}{k}}
319+
\FunctionTypeNamedArguments{T}{n}{x}{k}{r}}
287320

288321
% Used to specify function types with named parameters:
289322
% Arguments: Return type, spacer, type parameter name, bound name,
290323
% number of type parameters, parameter type, number of required parameters,
291-
% name of optional parameters, number of optional parameters.
324+
% name of optional parameters, number of optional parameters,
325+
% name of `required` symbol.
292326
\newcommand{\FunctionTypeNamed}[9]{%
293-
\FunctionType{#1}{#2}{#3}{#4}{#5}{%
294-
\FunctionTypeNamedArguments{#6}{#7}{#8}{#9}}}
327+
\FunctionType{#1}{#2}{#3}{#4}{#5}{\\
328+
\mbox{}\qquad\FunctionTypeNamedArguments{#6}{#7}{#8}{#9}{#10}}}
295329

296330
% Same as \FunctionType except suitable for inline usage, hence omitting
297331
% the spacer argument.
298-
\newcommand{\RawFunctionTypeNamed}[8]{%
332+
\newcommand{\RawFunctionTypeNamed}[9]{%
299333
\RawFunctionType{#1}{#2}{#3}{#4}{%
300-
\FunctionTypeNamedArguments{#5}{#6}{#7}{#8}}}
334+
\FunctionTypeNamedArguments{#5}{#6}{#7}{#8}{#9}}}
301335

302336
% Used to specify function types with no optional parameters:
303337
% Arguments: Return type, spacer, type parameter name, bound name,
@@ -313,10 +347,10 @@
313347
\RawFunctionTypePositional{#1}{X}{B}{s}{T}{n}{k}}
314348

315349
\newcommand{\FunctionTypeNamedStd}[1]{%
316-
\FunctionTypeNamed{#1}{ }{X}{B}{s}{T}{n}{x}{k}}
350+
\FunctionTypeNamed{#1}{ }{X}{B}{s}{T}{n}{x}{k}{r}}
317351

318352
\newcommand{\RawFunctionTypeNamedStd}[1]{%
319-
\RawFunctionTypeNamed{#1}{X}{B}{s}{T}{n}{x}{k}}
353+
\RawFunctionTypeNamed{#1}{X}{B}{s}{T}{n}{x}{k}{r}}
320354

321355
\newcommand{\FunctionTypeAllRequiredStd}[1]{%
322356
\FunctionTypeAllRequired{#1}{ }{X}{B}{s}{T}{n}}
@@ -325,7 +359,10 @@
325359
\FunctionTypePositional{#1}{\\}{X}{B}{s}{T}{n}{k}}
326360

327361
\newcommand{\FunctionTypeNamedStdCr}[1]{%
328-
\FunctionTypeNamed{#1}{\\}{X}{B}{s}{T}{n}{x}{k}}
362+
\FunctionTypeNamed{#1}{\\}{X}{B}{s}{T}{n}{x}{k}{r}}
363+
364+
\newcommand{\FunctionTypeNamedStdArgCr}[1]{%
365+
\FunctionTypeNamedArgCr{#1}{ }{X}{B}{s}{T}{n}{x}{k}{r}}
329366

330367
\newcommand{\FunctionTypeAllRequiredStdCr}[1]{%
331368
\FunctionTypeAllRequired{#1}{\\}{X}{B}{s}{T}{n}}
@@ -341,13 +378,13 @@
341378

342379
% Judgment expressing that a subtype relation exists.
343380
\newcommand{\Subtype}[3]{\ensuremath{{#1}\vdash{#2}\,<:\,{#3}}}
344-
\newcommand{\SubtypeStd}[2]{\Subtype{\Gamma}{#1}{#2}}
381+
\newcommand{\SubtypeStd}[2]{\Subtype{\Delta}{#1}{#2}}
345382
% Subtype judgment where the environment is omitted (NE: "no environment").
346383
\newcommand{\SubtypeNE}[2]{\ensuremath{{#1}\,<:\,{#2}}}
347384

348385
% Judgment expressing that a supertype relation exists.
349386
\newcommand{\Supertype}[3]{\ensuremath{{#1}\vdash{#2}\,:>\,{#3}}}
350-
\newcommand{\SupertypeStd}[2]{\Supertype{\Gamma}{#1}{#2}}
387+
\newcommand{\SupertypeStd}[2]{\Supertype{\Delta}{#1}{#2}}
351388

352389
% Judgment expressing that an assignability relation exists.
353390
\newcommand{\AssignableRelationSymbol}{\ensuremath{\Longleftrightarrow}}
@@ -387,6 +424,62 @@
387424
\newcommand{\EvaluateElementName}{\metavar{evaluateElement}}
388425
\newcommand{\EvaluateElement}[1]{\ensuremath{\EvaluateElementName({#1})}}
389426

427+
\newcommand{\FlattenName}{\metavar{flatten}}
428+
\newcommand{\Flatten}[1]{\ensuremath{\FlattenName(\code{#1})}}
429+
430+
\newcommand{\NominalTypeDepthName}{\metavar{nominalTypeDepth}}
431+
\newcommand{\NominalTypeDepth}[1]{%
432+
\ensuremath{\NominalTypeDepthName(\code{#1})}}
433+
434+
\newcommand{\TopMergeTypeName}{\metavar{topMergeType}}
435+
\newcommand{\TopMergeType}[2]{%
436+
\ensuremath{\TopMergeTypeName(\code{{#1},\,\,{#2}})}}
437+
438+
\newcommand{\NonNullTypeName}{\metavar{nonNullType}}
439+
\newcommand{\NonNullType}[1]{\ensuremath{\NonNullTypeName(\code{#1})}}
440+
441+
\newcommand{\IsTopTypeName}{\metavar{isTopType}}
442+
\newcommand{\IsTopType}[1]{\ensuremath{\IsTopTypeName(\code{#1})}}
443+
444+
\newcommand{\IsObjectTypeName}{\metavar{isObjectType}}
445+
\newcommand{\IsObjectType}[1]{\ensuremath{\IsObjectTypeName(\code{#1})}}
446+
447+
\newcommand{\IsBottomTypeName}{\metavar{isBottomType}}
448+
\newcommand{\IsBottomType}[1]{\ensuremath{\IsBottomTypeName(\code{#1})}}
449+
450+
\newcommand{\IsNullTypeName}{\metavar{isNullType}}
451+
\newcommand{\IsNullType}[1]{\ensuremath{\IsNullTypeName(\code{#1})}}
452+
453+
\newcommand{\IsMoreTopTypeName}{\metavar{isMoreTopType}}
454+
\newcommand{\IsMoreTopType}[2]{%
455+
\ensuremath{\IsMoreTopTypeName(\code{{#1},\,\,{#2}})}}
456+
457+
\newcommand{\IsMoreBottomTypeName}{\metavar{isMoreBottomType}}
458+
\newcommand{\IsMoreBottomType}[2]{%
459+
\ensuremath{\IsMoreBottomTypeName(\code{{#1},\,\,{#2}})}}
460+
461+
\newcommand{\NormalizedTypeOfName}{\metavar{normalizedType}}
462+
\newcommand{\NormalizedTypeOf}[1]{%
463+
\ensuremath{\NormalizedTypeOfName(\code{#1})}}
464+
465+
\newcommand{\FutureValueTypeOfName}{\metavar{futureValueType}}
466+
\newcommand{\FutureValueTypeOf}[1]{%
467+
\ensuremath{\FutureValueTypeOfName(\code{#1})}}
468+
469+
\newcommand{\UpperBoundTypeName}{\metavar{standardUpperBound}}
470+
\newcommand{\UpperBoundType}[2]{%
471+
\ensuremath{\UpperBoundTypeName(\code{{#1},\,\,{#2}})}}
472+
473+
\newcommand{\LowerBoundTypeName}{\metavar{standardLowerBound}}
474+
\newcommand{\LowerBoundType}[2]{%
475+
\ensuremath{\LowerBoundTypeName(\code{{#1},\,\,{#2}})}}
476+
477+
\newcommand{\DefEquals}[2]{\ensuremath{{#1}\stackrel{\vartriangle}{=}{#2}}}
478+
\newcommand{\DefEqualsNewline}[2]{
479+
\ensuremath{{#1}\stackrel{\vartriangle}{=}}\\
480+
\ensuremath{{#2}}%
481+
}
482+
390483
% ----------------------------------------------------------------------
391484
% Support for hash valued Location Markers
392485

0 commit comments

Comments
 (0)