@@ -15858,8 +15858,9 @@ \subsection{Null Shorting}
15858
15858
The semantics of the null aware member access operator \lit{?.}
15859
15859
is defined in terms of a program transformation known as
15860
15860
\Index{null shorting}.
15861
- This program transformation eliminates all occurrences of \lit{?.}
15862
- by introducing \LET{} expressions
15861
+ This program transformation transforms expressions
15862
+ and leaves other program elements unchanged.
15863
+ It eliminates all occurrences of \lit{?.} by introducing \LET{} expressions
15863
15864
(\ref{notation})
15864
15865
and equality comparisons with \NULL.
15865
15866
Null shorting is performed after the static analysis,
@@ -15869,8 +15870,8 @@ \subsection{Null Shorting}
15869
15870
\LMHash{}%
15870
15871
We use the phrase null-shorting as an adjective in order to
15871
15872
indicate the connections between null shorting and other concepts
15872
- (\commentary{
15873
- e.g., the null-shorting translation plays an important role in null shorting%
15873
+ (\commentary{%
15874
+ e.g., `` the null-shorting translation is used during null shorting'' %
15874
15875
}).
15875
15876
15876
15877
\commentary{%
@@ -15907,7 +15908,7 @@ \subsection{Null Shorting}
15907
15908
\IndexCustom{base-level}{null shorting!base-level}
15908
15909
to indicate that a term is Dart syntax,
15909
15910
as opposed to meta-level syntax.
15910
- \commentary{For example, \code{x\,\,+\,\,1}.}
15911
+ \commentary{For example, \code{x\,\,+\,\,1} is a base-level expression .}
15911
15912
15912
15913
\LMHash{}%
15913
15914
\metaCode{fn[x:\,\,Exp]:\,\,Exp\,\,=>\,\,E}
@@ -15917,7 +15918,7 @@ \subsection{Null Shorting}
15917
15918
and
15918
15919
\metaCode{fn[k:\,\,Exp\,\,$\rightarrow$\,\,Exp]:\,\,Exp\,\,=>\,\,E}
15919
15920
defines a meta-level function of type
15920
- \metaCode{Exp\,\,$\rightarrow$\,\,Exp\,\,$\rightarrow$\,\,Exp}.
15921
+ \metaCode{( Exp\,\,$\rightarrow$\,\,Exp) \,\,$\rightarrow$\,\,Exp}.
15921
15922
Where obvious from context,
15922
15923
we elide the parameter and return types on the meta-level functions.
15923
15924
The meta-variables \metaCode{F} and \metaCode{G}
@@ -15926,12 +15927,11 @@ \subsection{Null Shorting}
15926
15927
is written as \metaCode{F[p]}.
15927
15928
15928
15929
\LMHash{}%
15929
- Null shorting transforms an expression \metaCode{e}
15930
- (\commentary{whose meta-level type is \code{Exp}})
15930
+ Null shorting transforms an expression $e$
15931
15931
into a meta-level function \metaCode{F} of type
15932
15932
\metaCode{(Exp\,\,$\rightarrow$\,\,Exp)\,\,$\rightarrow$\,\,Exp},
15933
- which takes as an argument the continuation of \metaCode{e} ,
15934
- and produces an expression semantically equivalent to \metaCode{e}
15933
+ which takes as an argument the continuation of $e$ ,
15934
+ and produces an expression semantically equivalent to $e$
15935
15935
with all occurrences of \metaCode{?.} eliminated
15936
15936
in favor of explicit sequencing using \LET{} expressions.
15937
15937
@@ -15943,27 +15943,31 @@ \subsection{Null Shorting}
15943
15943
15944
15944
\LMHash{}%
15945
15945
The
15946
- \IndexCustom{expression translation}{null shorting!expression translation}
15947
- of an expression \metaCode{e} is
15948
- the result of applying the null-shorting translation
15949
- of \metaCode{e} to \metaCode{ID}.
15950
- That is, if \metaCode{e} translates to \metaCode{F},
15951
- then \metaCode{F[ID]} is the expression translation of \metaCode{e}.
15946
+ \IndexCustom{null-shorting expression translation}{%
15947
+ null shorting!expression translation}
15948
+ of an expression $e$
15949
+ (in this section abbreviated as the \NoIndex{expression translation} of $e$)
15950
+ is the result of applying the null-shorting translation (defined below)
15951
+ of $e$ to \metaCode{ID}.
15952
+ That is, if $e$ translates to \metaCode{F},
15953
+ then \metaCode{F[ID]} is the expression translation of $e$.
15952
15954
15953
15955
\LMHash{}%
15954
15956
We use
15955
- \IndexCustom{\metaCode{EXP(e)}}{null shorting!\metaCode{EXP(e)}}
15957
+ \IndexCustom{\metaCode{EXP(\textcolor{normativeColor}{$e$})}}{%
15958
+ null shorting!\metaCode{EXP(\textcolor{normativeColor}{$e$})}}
15956
15959
as a shorthand for
15957
- the expression translation of \metaCode{e} .
15958
- That is, if the null-shorting translation of \metaCode{e} is \metaCode{F},
15959
- then \metaCode{EXP(e )} is \metaCode{F[ID]}.
15960
+ the expression translation of $e$ .
15961
+ That is, if the null-shorting translation of $e$ is \metaCode{F},
15962
+ then \metaCode{EXP(\textcolor{normativeColor}{$e$} )} is \metaCode{F[ID]}.
15960
15963
15961
15964
\LMHash{}%
15962
15965
We extend the expression translation to argument lists in the obvious way,
15963
15966
using
15964
- \IndexCustom{\metaCode{ARGS(args)}}{null shorting!\metaCode{ARGS(args)}}
15967
+ \IndexCustom{\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}{%
15968
+ null shorting!\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}
15965
15969
to denote the result of applying the expression translation pointwise
15966
- to the arguments in the argument list \metaCode {args}.
15970
+ to the arguments in the argument list \metavar {args}.
15967
15971
15968
15972
\LMHash{}%
15969
15973
We use three combinators to express the translation.
@@ -15996,7 +16000,7 @@ \subsection{Null Shorting}
15996
16000
bound to the result of evaluating the receiver,
15997
16001
produces the final expression.
15998
16002
The result is parameterized over the continuation of
15999
- the expression being translated.
16003
+ the expression being translated (\metaCode{k}) .
16000
16004
The continuation is only called in the case that
16001
16005
the result of evaluating the receiver is non-null.
16002
16006
@@ -16196,8 +16200,8 @@ \subsection{Null Shorting}
16196
16200
\commentary{%
16197
16201
\begin{itemize}
16198
16202
\item
16199
- A list literal \Base{\code{[\,$e_1$, \ldots, $e_n$\, ]}}
16200
- translates to\\
16203
+ A list literal \Base{\code{[\List{e}{1}{n} ]}}
16204
+ translates to
16201
16205
\metaCode{TERM[\Base{[\,%
16202
16206
\Meta{EXP(\Base{$e_1$}), \ldots, EXP(\Base{$e_n$})}\,]}]}.
16203
16207
\item
0 commit comments