Skip to content

Commit 44c2a15

Browse files
committed
Small adjustments to Variables
1 parent b496c5c commit 44c2a15

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
@@ -1404,10 +1404,8 @@ \section{Variables}
14041404
A \IndexCustom{mutable variable}{variable!mutable}
14051405
is a variable which is not final.
14061406

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

14121410
\LMHash{}%
14131411
The following rules on implicitly induced getters and setters
@@ -1708,7 +1706,7 @@ \subsection{Evaluation of Implicit Variable Getters}
17081706
will evaluate to the object stored in \id.
17091707
Otherwise
17101708
(\commentary{when no value has been stored in this variable}),
1711-
the getter invocation will throw.
1709+
the getter invocation incurs a dynamic error.
17121710
\EndCase
17131711

17141712
\LMHash{}%
@@ -1765,7 +1763,17 @@ \subsection{Evaluation of Implicit Variable Getters}
17651763
and the most recent invocation of the getter \code{i}
17661764
returns 10.
17671765
This makes \code{i + 1} evaluate to 11,
1768-
which is stored in the variable.%
1766+
which is stored in the variable.
1767+
Finally, the invocation of the getter \code{i} in \code{main}
1768+
completes returning 11.%
1769+
}
1770+
1771+
\commentary{%
1772+
Note that this is a change from the semantics older versions of Dart:
1773+
Throwing an exception during initializer evaluation no longer sets the
1774+
variable to \code{null},
1775+
and reading the variable during initializer evaluation
1776+
no longer causes a dynamic error.%
17691777
}
17701778
\item \emph{Constant variable.}
17711779
If $d$ is of one of the forms
@@ -1807,7 +1815,9 @@ \subsection{Evaluation of Implicit Variable Getters}
18071815
in a situation where no object has been stored in the variable \id{}
18081816
will incur a dynamic error.
18091817
\end{itemize}
1810-
\EndCase
1818+
1819+
% Reduce whitespace after itemized list: This is just an end symbol.
1820+
\vspace{-\baselineskip}\EndCase
18111821

18121822

18131823
\section{Functions}
@@ -24722,41 +24732,9 @@ \subsubsection{Late fields and variables}
2472224732

2472324733
!!!TODO!!!
2472424734

24725-
A variable which is marked as \LATE{} ...
24726-
24727-
A read of a field or variable which is marked as \LATE{} which has not yet been
24728-
written to causes the initializer expression of the variable to be evaluated to
24729-
a value, assigned to the variable or field, and returned as the value of the
24730-
read.
24731-
24732-
\begin{itemize}
24733-
\item If there is no initializer expression, the read causes a runtime error to be
24734-
thrown.
24735-
\item Evaluating the initializer expression may validly cause a write to the field
24736-
or variable, assuming that the field or variable is not final. In this
24737-
case, the variable assumes the written value. The final value of the
24738-
initializer expression overwrites any intermediate written values.
24739-
\item Evaluating the initializer expression may cause an exception to be thrown.
24740-
If the variable was written to before the exception was thrown, the value of
24741-
the variable on subsequent reads is the last written value. If the variable
24742-
was not written before the exception was thrown, then the next read attempts
24743-
to evaluate the initializer expression again.
24744-
\item If a variable or field is read from during the process of evaluating its own
24745-
initializer expression, and no write to the variable has occurred, the read
24746-
is treated as a first read and the initializer expression is evaluated
24747-
again.
24748-
\end{itemize}
24749-
24750-
Let $D$ be a \LATE{} and \FINAL{} non-local variable declaration named \code{v}
24751-
without an initializing expression.
24752-
It is a run-time error, to invoke the setter \code{v=} which is
24753-
implicitly induced by $D$ if a value has previously been assigned to \code{v}
24754-
(which could be due to an initializing formal or a constructor initializer
24755-
list, or due to an invocation of the setter).
24756-
24757-
Let $D$ be a \LATE{} and \FINAL{} local variable declaration named \code{v}. It is a
24758-
run-time error, to assign a value to \code{v} if a value has previously
24759-
been assigned to \code{v}.
24735+
Let $D$ be a \LATE{} and \FINAL{} local variable declaration named \code{v}.
24736+
It is a run-time error, to assign a value to \code{v}
24737+
if a value has previously been assigned to \code{v}.
2476024738

2476124739
Note that this includes the implicit initializing writes induced by
2476224740
evaluating the initializer during a read. Hence, the following program
@@ -24770,16 +24748,6 @@ \subsubsection{Late fields and variables}
2477024748
\}
2477124749
\end{dartCode}
2477224750

24773-
A toplevel or class variable with an initializer is evaluated as if it
24774-
was marked \LATE. Note that this is a change from pre-NNBD semantics in that:
24775-
24776-
\begin{itemize}
24777-
\item Throwing an exception during initializer evaluation no longer sets the
24778-
variable to \code{null}
24779-
\item Reading the variable during initializer evaluation is no longer checked for,
24780-
and does not cause an error.
24781-
\end{itemize}
24782-
2478324751
\subsubsection{Boolean conditional evaluation}
2478424752

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

0 commit comments

Comments
 (0)