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