Skip to content

Commit ea49730

Browse files
committed
Small adjustments to Variables
1 parent 78c3484 commit ea49730

File tree

1 file changed

+20
-52
lines changed

1 file changed

+20
-52
lines changed

specification/dartLangSpec.tex

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,10 +1396,8 @@ \section{Variables}
13961396
A \IndexCustom{mutable variable}{variable!mutable}
13971397
is a variable which is not final.
13981398

1399-
%% Note that the following relies on the assumption that inference has
1400-
%% already taken place, including member signature inference. For instance,
1401-
%% if `var x;` is an instance variable declaration that overrides `T get x;`
1402-
%% then we treat `var x;` as if it had been `T x;`.
1399+
\subsection{Implicitly Induced Getters and Setters}
1400+
\LMLabel{implicitlyInducedGettersAndSetters}
14031401

14041402
\LMHash{}%
14051403
The following rules on implicitly induced getters and setters
@@ -1700,7 +1698,7 @@ \subsection{Evaluation of Implicit Variable Getters}
17001698
will evaluate to the object stored in \id.
17011699
Otherwise
17021700
(\commentary{when no value has been stored in this variable}),
1703-
the getter invocation will throw.
1701+
the getter invocation incurs a dynamic error.
17041702
\EndCase
17051703

17061704
\LMHash{}%
@@ -1757,7 +1755,17 @@ \subsection{Evaluation of Implicit Variable Getters}
17571755
and the most recent invocation of the getter \code{i}
17581756
returns 10.
17591757
This makes \code{i + 1} evaluate to 11,
1760-
which is stored in the variable.%
1758+
which is stored in the variable.
1759+
Finally, the invocation of the getter \code{i} in \code{main}
1760+
completes returning 11.%
1761+
}
1762+
1763+
\commentary{%
1764+
Note that this is a change from the semantics older versions of Dart:
1765+
Throwing an exception during initializer evaluation no longer sets the
1766+
variable to \code{null},
1767+
and reading the variable during initializer evaluation
1768+
no longer causes a dynamic error.%
17611769
}
17621770
\item \emph{Constant variable.}
17631771
If $d$ is of one of the forms
@@ -1799,7 +1807,9 @@ \subsection{Evaluation of Implicit Variable Getters}
17991807
in a situation where no object has been stored in the variable \id{}
18001808
will incur a dynamic error.
18011809
\end{itemize}
1802-
\EndCase
1810+
1811+
% Reduce whitespace after itemized list: This is just an end symbol.
1812+
\vspace{-\baselineskip}\EndCase
18031813

18041814

18051815
\section{Functions}
@@ -24583,41 +24593,9 @@ \subsubsection{Late fields and variables}
2458324593

2458424594
!!!TODO!!!
2458524595

24586-
A variable which is marked as \LATE{} ...
24587-
24588-
A read of a field or variable which is marked as \LATE{} which has not yet been
24589-
written to causes the initializer expression of the variable to be evaluated to
24590-
a value, assigned to the variable or field, and returned as the value of the
24591-
read.
24592-
24593-
\begin{itemize}
24594-
\item If there is no initializer expression, the read causes a runtime error to be
24595-
thrown.
24596-
\item Evaluating the initializer expression may validly cause a write to the field
24597-
or variable, assuming that the field or variable is not final. In this
24598-
case, the variable assumes the written value. The final value of the
24599-
initializer expression overwrites any intermediate written values.
24600-
\item Evaluating the initializer expression may cause an exception to be thrown.
24601-
If the variable was written to before the exception was thrown, the value of
24602-
the variable on subsequent reads is the last written value. If the variable
24603-
was not written before the exception was thrown, then the next read attempts
24604-
to evaluate the initializer expression again.
24605-
\item If a variable or field is read from during the process of evaluating its own
24606-
initializer expression, and no write to the variable has occurred, the read
24607-
is treated as a first read and the initializer expression is evaluated
24608-
again.
24609-
\end{itemize}
24610-
24611-
Let $D$ be a \LATE{} and \FINAL{} non-local variable declaration named \code{v}
24612-
without an initializing expression.
24613-
It is a run-time error, to invoke the setter \code{v=} which is
24614-
implicitly induced by $D$ if a value has previously been assigned to \code{v}
24615-
(which could be due to an initializing formal or a constructor initializer
24616-
list, or due to an invocation of the setter).
24617-
24618-
Let $D$ be a \LATE{} and \FINAL{} local variable declaration named \code{v}. It is a
24619-
run-time error, to assign a value to \code{v} if a value has previously
24620-
been assigned to \code{v}.
24596+
Let $D$ be a \LATE{} and \FINAL{} local variable declaration named \code{v}.
24597+
It is a run-time error, to assign a value to \code{v}
24598+
if a value has previously been assigned to \code{v}.
2462124599

2462224600
Note that this includes the implicit initializing writes induced by
2462324601
evaluating the initializer during a read. Hence, the following program
@@ -24631,16 +24609,6 @@ \subsubsection{Late fields and variables}
2463124609
\}
2463224610
\end{dartCode}
2463324611

24634-
A toplevel or class variable with an initializer is evaluated as if it
24635-
was marked \LATE. Note that this is a change from pre-NNBD semantics in that:
24636-
24637-
\begin{itemize}
24638-
\item Throwing an exception during initializer evaluation no longer sets the
24639-
variable to \code{null}
24640-
\item Reading the variable during initializer evaluation is no longer checked for,
24641-
and does not cause an error.
24642-
\end{itemize}
24643-
2464424612
\subsubsection{Boolean conditional evaluation}
2464524613

2464624614
The requirement that the condition in a boolean conditional control expression

0 commit comments

Comments
 (0)