Skip to content

Commit 2067652

Browse files
committed
Section Variables now in good state!
1 parent 66385af commit 2067652

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

specification/dartLangSpec.tex

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,8 @@ \section{Variables}
13761376
\LMHash{}%
13771377
The following rules on implicitly induced getters and setters
13781378
apply to all static and instance variables.
1379+
For each form of declaration mentioned,
1380+
the modifier \STATIC{} may be present or absent.
13791381

13801382
\LMHash{}%
13811383
A variable declaration of one of the forms
@@ -1443,7 +1445,7 @@ \section{Variables}
14431445

14441446
\LMHash{}%
14451447
A mutable variable declaration of the form
1446-
\code{\VAR\,\,\id;}
1448+
\code{\LATE?\,\,\VAR\,\,\id;}
14471449
induces an implicit setter function with header
14481450
\code{\VOID\,\,\SET\,\,\id(\DYNAMIC\,\,$x$)},
14491451
whose execution sets the value of \id{} to the incoming argument $x$.
@@ -1464,11 +1466,9 @@ \section{Variables}
14641466

14651467
\LMHash{}%
14661468
A variable declaration of the form
1467-
\code{\LATE\,\,\FINAL\,\,\id;} or
1468-
\code{\LATE\,\,\FINAL\,\,$T$\,\,\id;}
1469+
\code{\LATE\,\,\FINAL\,\,\id;}
14691470
induces an implicit setter function with header
1470-
\code{\VOID\,\,\SET\,\,\id($T$\,\,$x$)}
1471-
where $T$ is the static type of $e$ if present and otherwise \DYNAMIC.
1471+
\code{\VOID\,\,\SET\,\,\id(\DYNAMIC\,\,$x$)}.
14721472
The first execution of said setter sets the value of \id{} to
14731473
the incoming argument $x$,
14741474
and subsequent executions incur a dynamic error.
@@ -1598,21 +1598,19 @@ \subsection{Evaluation of Implicit Variable Getters}
15981598
\LMHash{}%
15991599
\BlindDefineSymbol{d, \id}%
16001600
Let $d$ be the declaration of a static or instance variable named \id.
1601-
\commentary{%
1602-
For brevity, we will refer to it as `the variable \id' or just `\id',
1603-
or as `the variable $d$' or just `$d$'.%
1604-
}
1601+
For brevity, we will refer to it below as
1602+
`the variable \id' or `the variable $d$', or just as `\id' or `$d$'.
16051603

16061604
\LMHash{}%
16071605
\Case{Non-late instance variable}
1608-
If $d$ is an instance variable which does not have the modifier \LATE,
1606+
If $d$ declares an instance variable which does not have the modifier \LATE,
16091607
then the invocation of the implicit getter of \id{} evaluates to
16101608
the object stored in \id.
16111609
\EndCase
16121610

16131611
\LMHash{}%
16141612
\Case{Late, initialized instance variable}
1615-
If $d$ is an instance variable which has the modifier \LATE{}
1613+
If $d$ declares an instance variable which has the modifier \LATE{}
16161614
and an initializing expression $e$,
16171615
then the first invocation of the implicit getter of \id{}
16181616
will evaluate $e$ to an object $o$, store $o$ in \id{},
@@ -1639,7 +1637,7 @@ \subsection{Evaluation of Implicit Variable Getters}
16391637

16401638
\LMHash{}%
16411639
\Case{Late, uninitialized instance variable}
1642-
Consider the case where $d$ is an instance variable
1640+
Consider the case where $d$ declares an instance variable
16431641
which has the modifier \LATE{} and no initializing expression.
16441642
Assume that the corresponding setter has been executed and did not throw.
16451643
In this case, an invocation of the implicit getter of \id{}
@@ -1650,49 +1648,48 @@ \subsection{Evaluation of Implicit Variable Getters}
16501648

16511649
\LMHash{}%
16521650
\Case{Static variable}
1653-
If $d$ is a static variable
1651+
If $d$ declares a static variable
16541652
(\commentary{that is, a library variable or a class variable}),
16551653
the implicit getter method of \id{} executes as follows:
16561654

16571655
\begin{itemize}
16581656
\item \emph{Non-constant variable with an initializer.}
1659-
Consider the case where the declaration $d$ has one of the forms
1660-
\code{\LATE?\,\,\VAR\,\,\id{} = $e$;},
1661-
\code{\LATE?\,\,$T$\,\,\id{} = $e$;},\\
1662-
\code{\LATE?\,\,\FINAL\,\,\id{} = $e$;},
1663-
\code{\LATE?\,\,\FINAL\,\,$T$\,\,\id{} = $e$;},
1664-
\code{\STATIC\,\,\LATE?\,\,\id{} = $e$;},\\
1665-
\code{\STATIC\,\,\LATE?\,\,$T$\,\,\id{} = $e$;},
1666-
\code{\STATIC\,\,\LATE?\,\,\FINAL\,\,\id{} = $e$;},\\
1667-
or
1668-
\code{\STATIC\,\,\LATE?\,\,\FINAL\,\,$T$\,\,\id{} = $e$;}.
1669-
1670-
1671-
no object has yet been stored into \id{}
1672-
then the initializing expression $e$ is evaluated.
1673-
1674-
1675-
If the evaluation of $e$ throws an exception $e$ and stack trace $s$,
1676-
the null object (\ref{null}) is stored into $v$;
1677-
the execution of the getter then throws $e$ and stack trace $s$.
1678-
Otherwise, the evaluation of $e$ succeeded yielding an object $o$;
1679-
then $o$ is stored into $v$ and
1680-
the execution of the getter completes by returning $o$.
1681-
Otherwise,
1682-
(\commentary{when an object $o$ has been stored in $v$})
1683-
execution of the getter completes by returning $o$.
1657+
Consider the case where $d$ has one of the forms
1658+
\code{\STATIC?\,\,\LATE?\,\,\VAR\,\,\id{} = $e$;},
1659+
\code{\STATIC?\,\,\LATE?\,\,\FINAL\,\,\id{} = $e$;}, or
1660+
\code{\STATIC?\,\,\LATE?\,\,\FINAL?\,\,$T$\,\,\id{} = $e$;}.
1661+
1662+
The first invocation of the implicit getter of \id{}
1663+
will evaluate $e$ to an object $o$, store $o$ in \id{},
1664+
and evaluate to $o$;
1665+
if the evaluation of $e$ throws,
1666+
the invocation of the getter throws the same object and stack trace,
1667+
and the next invocation of the implicit getter of \id{}
1668+
is considered to be the first invocation.
1669+
A non-first invocation of the implicit getter of \id{} evaluates to
1670+
the object stored in \id.
1671+
1672+
If \id{} has an implicitly induced setter,
1673+
and this setter is invoked and completes normally,
1674+
the next execution of the implicitly induced getter of \id{}
1675+
is considered to be non-first.
1676+
1677+
\commentary{%
1678+
Note that the setter of a \LATE\,\,\FINAL{} variable
1679+
without an initializing expression
1680+
will throw if it is invoked multiple times.%
1681+
}
16841682
\item \emph{Constant variable.}
16851683
If $d$ is of one of the forms
1686-
\code{\LATE?\,\,\CONST{} $v$ = $e$;},
1687-
\code{\LATE?\,\,\CONST{} $T$ $v$ = $e$;},
1688-
\code{\LATE?\,\,\STATIC{} \CONST{} $v$ = $e$;} or
1689-
\code{\LATE?\,\,\STATIC{} \CONST{} $T$ $v$ = $e$;}
1684+
\code{\STATIC?\,\,\LATE?\,\,\CONST{} $v$ = $e$;} or
1685+
\code{\STATIC?\,\,\LATE?\,\,\CONST{} $T$ $v$ = $e$;}.
16901686
the result of the getter is the value of the constant expression $e$.
16911687
\commentary{%
16921688
Note that a constant expression cannot depend on itself,
16931689
so no cyclic references can occur.%
16941690
}
16951691
\item \emph{Variable without an initializer.}
1692+
16961693
The result of executing the getter method is the object stored in $v$.
16971694
\commentary{This may be the initial value, that is, the null object.}
16981695
\end{itemize}

0 commit comments

Comments
 (0)