@@ -15838,8 +15838,9 @@ \subsection{Null Shorting}
15838
15838
The semantics of the null aware member access operator \lit{?.}
15839
15839
is defined in terms of a program transformation known as
15840
15840
\Index{null shorting}.
15841
- This program transformation eliminates all occurrences of \lit{?.}
15842
- by introducing \LET{} expressions
15841
+ This program transformation transforms expressions
15842
+ and leaves other program elements unchanged.
15843
+ It eliminates all occurrences of \lit{?.} by introducing \LET{} expressions
15843
15844
(\ref{notation})
15844
15845
and equality comparisons with \NULL.
15845
15846
Null shorting is performed after the static analysis,
@@ -15849,8 +15850,8 @@ \subsection{Null Shorting}
15849
15850
\LMHash{}%
15850
15851
We use the phrase null-shorting as an adjective in order to
15851
15852
indicate the connections between null shorting and other concepts
15852
- (\commentary{
15853
- e.g., the null-shorting translation plays an important role in null shorting%
15853
+ (\commentary{%
15854
+ e.g., `` the null-shorting translation is used during null shorting'' %
15854
15855
}).
15855
15856
15856
15857
\commentary{%
@@ -15887,7 +15888,7 @@ \subsection{Null Shorting}
15887
15888
\IndexCustom{base-level}{null shorting!base-level}
15888
15889
to indicate that a term is Dart syntax,
15889
15890
as opposed to meta-level syntax.
15890
- \commentary{For example, \code{x\,\,+\,\,1}.}
15891
+ \commentary{For example, \code{x\,\,+\,\,1} is a base-level expression .}
15891
15892
15892
15893
\LMHash{}%
15893
15894
\metaCode{fn[x:\,\,Exp]:\,\,Exp\,\,=>\,\,E}
@@ -15897,7 +15898,7 @@ \subsection{Null Shorting}
15897
15898
and
15898
15899
\metaCode{fn[k:\,\,Exp\,\,$\rightarrow$\,\,Exp]:\,\,Exp\,\,=>\,\,E}
15899
15900
defines a meta-level function of type
15900
- \metaCode{Exp\,\,$\rightarrow$\,\,Exp\,\,$\rightarrow$\,\,Exp}.
15901
+ \metaCode{( Exp\,\,$\rightarrow$\,\,Exp) \,\,$\rightarrow$\,\,Exp}.
15901
15902
Where obvious from context,
15902
15903
we elide the parameter and return types on the meta-level functions.
15903
15904
The meta-variables \metaCode{F} and \metaCode{G}
@@ -15906,12 +15907,11 @@ \subsection{Null Shorting}
15906
15907
is written as \metaCode{F[p]}.
15907
15908
15908
15909
\LMHash{}%
15909
- Null shorting transforms an expression \metaCode{e}
15910
- (\commentary{whose meta-level type is \code{Exp}})
15910
+ Null shorting transforms an expression $e$
15911
15911
into a meta-level function \metaCode{F} of type
15912
15912
\metaCode{(Exp\,\,$\rightarrow$\,\,Exp)\,\,$\rightarrow$\,\,Exp},
15913
- which takes as an argument the continuation of \metaCode{e} ,
15914
- and produces an expression semantically equivalent to \metaCode{e}
15913
+ which takes as an argument the continuation of $e$ ,
15914
+ and produces an expression semantically equivalent to $e$
15915
15915
with all occurrences of \metaCode{?.} eliminated
15916
15916
in favor of explicit sequencing using \LET{} expressions.
15917
15917
@@ -15923,27 +15923,31 @@ \subsection{Null Shorting}
15923
15923
15924
15924
\LMHash{}%
15925
15925
The
15926
- \IndexCustom{expression translation}{null shorting!expression translation}
15927
- of an expression \metaCode{e} is
15928
- the result of applying the null-shorting translation
15929
- of \metaCode{e} to \metaCode{ID}.
15930
- That is, if \metaCode{e} translates to \metaCode{F},
15931
- then \metaCode{F[ID]} is the expression translation of \metaCode{e}.
15926
+ \IndexCustom{null-shorting expression translation}{%
15927
+ null shorting!expression translation}
15928
+ of an expression $e$
15929
+ (in this section abbreviated as the \NoIndex{expression translation} of $e$)
15930
+ is the result of applying the null-shorting translation (defined below)
15931
+ of $e$ to \metaCode{ID}.
15932
+ That is, if $e$ translates to \metaCode{F},
15933
+ then \metaCode{F[ID]} is the expression translation of $e$.
15932
15934
15933
15935
\LMHash{}%
15934
15936
We use
15935
- \IndexCustom{\metaCode{EXP(e)}}{null shorting!\metaCode{EXP(e)}}
15937
+ \IndexCustom{\metaCode{EXP(\textcolor{normativeColor}{$e$})}}{%
15938
+ null shorting!\metaCode{EXP(\textcolor{normativeColor}{$e$})}}
15936
15939
as a shorthand for
15937
- the expression translation of \metaCode{e} .
15938
- That is, if the null-shorting translation of \metaCode{e} is \metaCode{F},
15939
- then \metaCode{EXP(e )} is \metaCode{F[ID]}.
15940
+ the expression translation of $e$ .
15941
+ That is, if the null-shorting translation of $e$ is \metaCode{F},
15942
+ then \metaCode{EXP(\textcolor{normativeColor}{$e$} )} is \metaCode{F[ID]}.
15940
15943
15941
15944
\LMHash{}%
15942
15945
We extend the expression translation to argument lists in the obvious way,
15943
15946
using
15944
- \IndexCustom{\metaCode{ARGS(args)}}{null shorting!\metaCode{ARGS(args)}}
15947
+ \IndexCustom{\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}{%
15948
+ null shorting!\metaCode{ARGS(\textcolor{normativeColor}{\metavar{args}})}}
15945
15949
to denote the result of applying the expression translation pointwise
15946
- to the arguments in the argument list \metaCode {args}.
15950
+ to the arguments in the argument list \metavar {args}.
15947
15951
15948
15952
\LMHash{}%
15949
15953
We use three combinators to express the translation.
@@ -15976,7 +15980,7 @@ \subsection{Null Shorting}
15976
15980
bound to the result of evaluating the receiver,
15977
15981
produces the final expression.
15978
15982
The result is parameterized over the continuation of
15979
- the expression being translated.
15983
+ the expression being translated (\metaCode{k}) .
15980
15984
The continuation is only called in the case that
15981
15985
the result of evaluating the receiver is non-null.
15982
15986
@@ -16176,8 +16180,8 @@ \subsection{Null Shorting}
16176
16180
\commentary{%
16177
16181
\begin{itemize}
16178
16182
\item
16179
- A list literal \Base{\code{[\,$e_1$, \ldots, $e_n$\, ]}}
16180
- translates to\\
16183
+ A list literal \Base{\code{[\List{e}{1}{n} ]}}
16184
+ translates to
16181
16185
\metaCode{TERM[\Base{[\,%
16182
16186
\Meta{EXP(\Base{$e_1$}), \ldots, EXP(\Base{$e_n$})}\,]}]}.
16183
16187
\item
0 commit comments