@@ -16176,8 +16176,9 @@ \subsection{Null Shorting}
16176
16176
The semantics of the null aware member access operator \lit{?.}
16177
16177
is defined in terms of a program transformation known as
16178
16178
\Index{null shorting}.
16179
- This program transformation eliminates all occurrences of \lit{?.}
16180
- by introducing \LET{} expressions
16179
+ This program transformation transforms expressions
16180
+ and leaves other program elements unchanged.
16181
+ It eliminates all occurrences of \lit{?.} by introducing \LET{} expressions
16181
16182
(\ref{notation})
16182
16183
and equality comparisons with \NULL.
16183
16184
Null shorting is performed after the static analysis,
@@ -16187,8 +16188,8 @@ \subsection{Null Shorting}
16187
16188
\LMHash{}%
16188
16189
We use the phrase null-shorting as an adjective in order to
16189
16190
indicate the connections between null shorting and other concepts
16190
- (\commentary{
16191
- e.g., the null-shorting translation plays an important role in null shorting%
16191
+ (\commentary{%
16192
+ e.g., `` the null-shorting translation is used during null shorting'' %
16192
16193
}).
16193
16194
16194
16195
\commentary{%
@@ -16225,7 +16226,7 @@ \subsection{Null Shorting}
16225
16226
\IndexCustom{base-level}{null shorting!base-level}
16226
16227
to indicate that a term is Dart syntax,
16227
16228
as opposed to meta-level syntax.
16228
- \commentary{For example, \code{x\,\,+\,\,1}.}
16229
+ \commentary{For example, \code{x\,\,+\,\,1} is a base-level expression .}
16229
16230
16230
16231
\LMHash{}%
16231
16232
\metaCode{fn[x:\,\,Exp]:\,\,Exp\,\,=>\,\,E}
@@ -16235,7 +16236,7 @@ \subsection{Null Shorting}
16235
16236
and
16236
16237
\metaCode{fn[k:\,\,Exp\,\,$\rightarrow$\,\,Exp]:\,\,Exp\,\,=>\,\,E}
16237
16238
defines a meta-level function of type
16238
- \metaCode{Exp\,\,$\rightarrow$\,\,Exp\,\,$\rightarrow$\,\,Exp}.
16239
+ \metaCode{( Exp\,\,$\rightarrow$\,\,Exp) \,\,$\rightarrow$\,\,Exp}.
16239
16240
Where obvious from context,
16240
16241
we elide the parameter and return types on the meta-level functions.
16241
16242
The meta-variables \metaCode{F} and \metaCode{G}
@@ -16244,12 +16245,11 @@ \subsection{Null Shorting}
16244
16245
is written as \metaCode{F[p]}.
16245
16246
16246
16247
\LMHash{}%
16247
- Null shorting transforms an expression \metaCode{e}
16248
- (\commentary{whose meta-level type is \code{Exp}})
16248
+ Null shorting transforms an expression $e$
16249
16249
into a meta-level function \metaCode{F} of type
16250
16250
\metaCode{(Exp\,\,$\rightarrow$\,\,Exp)\,\,$\rightarrow$\,\,Exp},
16251
- which takes as an argument the continuation of \metaCode{e} ,
16252
- and produces an expression semantically equivalent to \metaCode{e}
16251
+ which takes as an argument the continuation of $e$ ,
16252
+ and produces an expression semantically equivalent to $e$
16253
16253
with all occurrences of \metaCode{?.} eliminated
16254
16254
in favor of explicit sequencing using \LET{} expressions.
16255
16255
@@ -16261,27 +16261,31 @@ \subsection{Null Shorting}
16261
16261
16262
16262
\LMHash{}%
16263
16263
The
16264
- \IndexCustom{expression translation}{null shorting!expression translation}
16265
- of an expression \metaCode{e} is
16266
- the result of applying the null-shorting translation
16267
- of \metaCode{e} to \metaCode{ID}.
16268
- That is, if \metaCode{e} translates to \metaCode{F},
16269
- then \metaCode{F[ID]} is the expression translation of \metaCode{e}.
16264
+ \IndexCustom{null-shorting expression translation}{%
16265
+ null shorting!expression translation}
16266
+ of an expression $e$
16267
+ (in this section abbreviated as the \NoIndex{expression translation} of $e$)
16268
+ is the result of applying the null-shorting translation (defined below)
16269
+ of $e$ to \metaCode{ID}.
16270
+ That is, if $e$ translates to \metaCode{F},
16271
+ then \metaCode{F[ID]} is the expression translation of $e$.
16270
16272
16271
16273
\LMHash{}%
16272
16274
We use
16273
- \IndexCustom{\metaCode{EXP(e)}}{null shorting!\metaCode{EXP(e)}}
16275
+ \IndexCustom{\metaCode{EXP(\textcolor{normativeColor}{$e$})}}{%
16276
+ null shorting!\metaCode{EXP(\textcolor{normativeColor}{$e$})}}
16274
16277
as a shorthand for
16275
- the expression translation of \metaCode{e} .
16276
- That is, if the null-shorting translation of \metaCode{e} is \metaCode{F},
16277
- then \metaCode{EXP(e )} is \metaCode{F[ID]}.
16278
+ the expression translation of $e$ .
16279
+ That is, if the null-shorting translation of $e$ is \metaCode{F},
16280
+ then \metaCode{EXP(\textcolor{normativeColor}{$e$} )} is \metaCode{F[ID]}.
16278
16281
16279
16282
\LMHash{}%
16280
16283
We extend the expression translation to argument lists in the obvious way,
16281
16284
using
16282
- \IndexCustom{\metaCode{ARGS(args)}}{null shorting!\metaCode{ARGS(args)}}
16285
+ \IndexCustom{\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}{%
16286
+ null shorting!\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}
16283
16287
to denote the result of applying the expression translation pointwise
16284
- to the arguments in the argument list \metaCode {args}.
16288
+ to the arguments in the argument list \metavar {args}.
16285
16289
16286
16290
\LMHash{}%
16287
16291
We use three combinators to express the translation.
@@ -16314,7 +16318,7 @@ \subsection{Null Shorting}
16314
16318
bound to the result of evaluating the receiver,
16315
16319
produces the final expression.
16316
16320
The result is parameterized over the continuation of
16317
- the expression being translated.
16321
+ the expression being translated (\metaCode{k}) .
16318
16322
The continuation is only called in the case that
16319
16323
the result of evaluating the receiver is non-null.
16320
16324
@@ -16514,8 +16518,8 @@ \subsection{Null Shorting}
16514
16518
\commentary{%
16515
16519
\begin{itemize}
16516
16520
\item
16517
- A list literal \Base{\code{[\,$e_1$, \ldots, $e_n$\, ]}}
16518
- translates to\\
16521
+ A list literal \Base{\code{[\List{e}{1}{n} ]}}
16522
+ translates to
16519
16523
\metaCode{TERM[\Base{[\,%
16520
16524
\Meta{EXP(\Base{$e_1$}), \ldots, EXP(\Base{$e_n$})}\,]}]}.
16521
16525
\item
0 commit comments