Skip to content

Commit 23cc4ad

Browse files
committed
Small adjustments to Variables
1 parent aa3fba7 commit 23cc4ad

File tree

1 file changed

+17
-47
lines changed

1 file changed

+17
-47
lines changed

specification/dartLangSpec.tex

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,17 @@ \subsection{Evaluation of Implicit Variable Getters}
19231923
and the most recent invocation of the getter \code{i}
19241924
returns 10.
19251925
This makes \code{i + 1} evaluate to 11,
1926-
which is stored in the variable.%
1926+
which is stored in the variable.
1927+
Finally, the invocation of the getter \code{i} in \code{main}
1928+
completes returning 11.%
1929+
}
1930+
1931+
\commentary{%
1932+
Note that this is a change from the semantics older versions of Dart:
1933+
Throwing an exception during initializer evaluation no longer sets the
1934+
variable to \code{null},
1935+
and reading the variable during initializer evaluation
1936+
no longer causes a dynamic error.%
19271937
}
19281938
\item \emph{Constant variable.}
19291939
If $d$ declares a constant variable with the initializing expression $e$,
@@ -1951,7 +1961,9 @@ \subsection{Evaluation of Implicit Variable Getters}
19511961
the implicitly induced getter is a late-uninitialized getter.
19521962
This determines the semantics of an invocation.
19531963
\end{itemize}
1954-
\EndCase
1964+
1965+
% Reduce whitespace after itemized list: This is just an end symbol.
1966+
\vspace{-\baselineskip}\EndCase
19551967

19561968
% Reduce whitespace after itemized list: This is just an end symbol.
19571969
\vspace{-\baselineskip}\EndCase
@@ -24932,41 +24944,9 @@ \subsubsection{Late fields and variables}
2493224944

2493324945
!!!TODO!!!
2493424946

24935-
A variable which is marked as \LATE{} ...
24936-
24937-
A read of a field or variable which is marked as \LATE{} which has not yet been
24938-
written to causes the initializer expression of the variable to be evaluated to
24939-
a value, assigned to the variable or field, and returned as the value of the
24940-
read.
24941-
24942-
\begin{itemize}
24943-
\item If there is no initializer expression, the read causes a runtime error to be
24944-
thrown.
24945-
\item Evaluating the initializer expression may validly cause a write to the field
24946-
or variable, assuming that the field or variable is not final. In this
24947-
case, the variable assumes the written value. The final value of the
24948-
initializer expression overwrites any intermediate written values.
24949-
\item Evaluating the initializer expression may cause an exception to be thrown.
24950-
If the variable was written to before the exception was thrown, the value of
24951-
the variable on subsequent reads is the last written value. If the variable
24952-
was not written before the exception was thrown, then the next read attempts
24953-
to evaluate the initializer expression again.
24954-
\item If a variable or field is read from during the process of evaluating its own
24955-
initializer expression, and no write to the variable has occurred, the read
24956-
is treated as a first read and the initializer expression is evaluated
24957-
again.
24958-
\end{itemize}
24959-
24960-
Let $D$ be a \LATE{} and \FINAL{} non-local variable declaration named \code{v}
24961-
without an initializing expression.
24962-
It is a run-time error, to invoke the setter \code{v=} which is
24963-
implicitly induced by $D$ if a value has previously been assigned to \code{v}
24964-
(which could be due to an initializing formal or a constructor initializer
24965-
list, or due to an invocation of the setter).
24966-
24967-
Let $D$ be a \LATE{} and \FINAL{} local variable declaration named \code{v}. It is a
24968-
run-time error, to assign a value to \code{v} if a value has previously
24969-
been assigned to \code{v}.
24947+
Let $D$ be a \LATE{} and \FINAL{} local variable declaration named \code{v}.
24948+
It is a run-time error, to assign a value to \code{v}
24949+
if a value has previously been assigned to \code{v}.
2497024950

2497124951
Note that this includes the implicit initializing writes induced by
2497224952
evaluating the initializer during a read. Hence, the following program
@@ -24980,16 +24960,6 @@ \subsubsection{Late fields and variables}
2498024960
\}
2498124961
\end{dartCode}
2498224962

24983-
A toplevel or class variable with an initializer is evaluated as if it
24984-
was marked \LATE. Note that this is a change from pre-NNBD semantics in that:
24985-
24986-
\begin{itemize}
24987-
\item Throwing an exception during initializer evaluation no longer sets the
24988-
variable to \code{null}
24989-
\item Reading the variable during initializer evaluation is no longer checked for,
24990-
and does not cause an error.
24991-
\end{itemize}
24992-
2499324963
\subsubsection{Boolean conditional evaluation}
2499424964

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

0 commit comments

Comments
 (0)