@@ -15521,8 +15521,9 @@ \subsection{Null Shorting}
15521
15521
The semantics of the null aware member access operator \lit{?.}
15522
15522
is defined in terms of a program transformation known as
15523
15523
\Index{null shorting}.
15524
- This program transformation eliminates all occurrences of \lit{?.}
15525
- by introducing \LET{} expressions
15524
+ This program transformation transforms expressions
15525
+ and leaves other program elements unchanged.
15526
+ It eliminates all occurrences of \lit{?.} by introducing \LET{} expressions
15526
15527
(\ref{notation})
15527
15528
and equality comparisons with \NULL.
15528
15529
Null shorting is performed after the static analysis,
@@ -15532,8 +15533,8 @@ \subsection{Null Shorting}
15532
15533
\LMHash{}%
15533
15534
We use the phrase null-shorting as an adjective in order to
15534
15535
indicate the connections between null shorting and other concepts
15535
- (\commentary{
15536
- e.g., the null-shorting translation plays an important role in null shorting%
15536
+ (\commentary{%
15537
+ e.g., `` the null-shorting translation is used during null shorting'' %
15537
15538
}).
15538
15539
15539
15540
\commentary{%
@@ -15570,7 +15571,7 @@ \subsection{Null Shorting}
15570
15571
\IndexCustom{base-level}{null shorting!base-level}
15571
15572
to indicate that a term is Dart syntax,
15572
15573
as opposed to meta-level syntax.
15573
- \commentary{For example, \code{x\,\,+\,\,1}.}
15574
+ \commentary{For example, \code{x\,\,+\,\,1} is a base-level expression .}
15574
15575
15575
15576
\LMHash{}%
15576
15577
\metaCode{fn[x:\,\,Exp]:\,\,Exp\,\,=>\,\,E}
@@ -15580,7 +15581,7 @@ \subsection{Null Shorting}
15580
15581
and
15581
15582
\metaCode{fn[k:\,\,Exp\,\,$\rightarrow$\,\,Exp]:\,\,Exp\,\,=>\,\,E}
15582
15583
defines a meta-level function of type
15583
- \metaCode{Exp\,\,$\rightarrow$\,\,Exp\,\,$\rightarrow$\,\,Exp}.
15584
+ \metaCode{( Exp\,\,$\rightarrow$\,\,Exp) \,\,$\rightarrow$\,\,Exp}.
15584
15585
Where obvious from context,
15585
15586
we elide the parameter and return types on the meta-level functions.
15586
15587
The meta-variables \metaCode{F} and \metaCode{G}
@@ -15589,12 +15590,11 @@ \subsection{Null Shorting}
15589
15590
is written as \metaCode{F[p]}.
15590
15591
15591
15592
\LMHash{}%
15592
- Null shorting transforms an expression \metaCode{e}
15593
- (\commentary{whose meta-level type is \code{Exp}})
15593
+ Null shorting transforms an expression $e$
15594
15594
into a meta-level function \metaCode{F} of type
15595
15595
\metaCode{(Exp\,\,$\rightarrow$\,\,Exp)\,\,$\rightarrow$\,\,Exp},
15596
- which takes as an argument the continuation of \metaCode{e} ,
15597
- and produces an expression semantically equivalent to \metaCode{e}
15596
+ which takes as an argument the continuation of $e$ ,
15597
+ and produces an expression semantically equivalent to $e$
15598
15598
with all occurrences of \metaCode{?.} eliminated
15599
15599
in favor of explicit sequencing using \LET{} expressions.
15600
15600
@@ -15606,27 +15606,31 @@ \subsection{Null Shorting}
15606
15606
15607
15607
\LMHash{}%
15608
15608
The
15609
- \IndexCustom{expression translation}{null shorting!expression translation}
15610
- of an expression \metaCode{e} is
15611
- the result of applying the null-shorting translation
15612
- of \metaCode{e} to \metaCode{ID}.
15613
- That is, if \metaCode{e} translates to \metaCode{F},
15614
- then \metaCode{F[ID]} is the expression translation of \metaCode{e}.
15609
+ \IndexCustom{null-shorting expression translation}{%
15610
+ null shorting!expression translation}
15611
+ of an expression $e$
15612
+ (in this section abbreviated as the \NoIndex{expression translation} of $e$)
15613
+ is the result of applying the null-shorting translation (defined below)
15614
+ of $e$ to \metaCode{ID}.
15615
+ That is, if $e$ translates to \metaCode{F},
15616
+ then \metaCode{F[ID]} is the expression translation of $e$.
15615
15617
15616
15618
\LMHash{}%
15617
15619
We use
15618
- \IndexCustom{\metaCode{EXP(e)}}{null shorting!\metaCode{EXP(e)}}
15620
+ \IndexCustom{\metaCode{EXP(\textcolor{normativeColor}{$e$})}}{%
15621
+ null shorting!\metaCode{EXP(\textcolor{normativeColor}{$e$})}}
15619
15622
as a shorthand for
15620
- the expression translation of \metaCode{e} .
15621
- That is, if the null-shorting translation of \metaCode{e} is \metaCode{F},
15622
- then \metaCode{EXP(e )} is \metaCode{F[ID]}.
15623
+ the expression translation of $e$ .
15624
+ That is, if the null-shorting translation of $e$ is \metaCode{F},
15625
+ then \metaCode{EXP(\textcolor{normativeColor}{$e$} )} is \metaCode{F[ID]}.
15623
15626
15624
15627
\LMHash{}%
15625
15628
We extend the expression translation to argument lists in the obvious way,
15626
15629
using
15627
- \IndexCustom{\metaCode{ARGS(args)}}{null shorting!\metaCode{ARGS(args)}}
15630
+ \IndexCustom{\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}{%
15631
+ null shorting!\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}
15628
15632
to denote the result of applying the expression translation pointwise
15629
- to the arguments in the argument list \metaCode {args}.
15633
+ to the arguments in the argument list \metavar {args}.
15630
15634
15631
15635
\LMHash{}%
15632
15636
We use three combinators to express the translation.
@@ -15659,7 +15663,7 @@ \subsection{Null Shorting}
15659
15663
bound to the result of evaluating the receiver,
15660
15664
produces the final expression.
15661
15665
The result is parameterized over the continuation of
15662
- the expression being translated.
15666
+ the expression being translated (\metaCode{k}) .
15663
15667
The continuation is only called in the case that
15664
15668
the result of evaluating the receiver is non-null.
15665
15669
@@ -15859,8 +15863,8 @@ \subsection{Null Shorting}
15859
15863
\commentary{%
15860
15864
\begin{itemize}
15861
15865
\item
15862
- A list literal \Base{\code{[\,$e_1$, \ldots, $e_n$\, ]}}
15863
- translates to\\
15866
+ A list literal \Base{\code{[\List{e}{1}{n} ]}}
15867
+ translates to
15864
15868
\metaCode{TERM[\Base{[\,%
15865
15869
\Meta{EXP(\Base{$e_1$}), \ldots, EXP(\Base{$e_n$})}\,]}]}.
15866
15870
\item
0 commit comments