@@ -1376,6 +1376,8 @@ \section{Variables}
1376
1376
\LMHash{}%
1377
1377
The following rules on implicitly induced getters and setters
1378
1378
apply to all static and instance variables.
1379
+ For each form of declaration mentioned,
1380
+ the modifier \STATIC{} may be present or absent.
1379
1381
1380
1382
\LMHash{}%
1381
1383
A variable declaration of one of the forms
@@ -1443,7 +1445,7 @@ \section{Variables}
1443
1445
1444
1446
\LMHash{}%
1445
1447
A mutable variable declaration of the form
1446
- \code{\VAR\,\,\id;}
1448
+ \code{\LATE?\,\,\ VAR\,\,\id;}
1447
1449
induces an implicit setter function with header
1448
1450
\code{\VOID\,\,\SET\,\,\id(\DYNAMIC\,\,$x$)},
1449
1451
whose execution sets the value of \id{} to the incoming argument $x$.
@@ -1464,11 +1466,9 @@ \section{Variables}
1464
1466
1465
1467
\LMHash{}%
1466
1468
A variable declaration of the form
1467
- \code{\LATE\,\,\FINAL\,\,\id;} or
1468
- \code{\LATE\,\,\FINAL\,\,$T$\,\,\id;}
1469
+ \code{\LATE\,\,\FINAL\,\,\id;}
1469
1470
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$)}.
1472
1472
The first execution of said setter sets the value of \id{} to
1473
1473
the incoming argument $x$,
1474
1474
and subsequent executions incur a dynamic error.
@@ -1598,21 +1598,19 @@ \subsection{Evaluation of Implicit Variable Getters}
1598
1598
\LMHash{}%
1599
1599
\BlindDefineSymbol{d, \id}%
1600
1600
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$'.
1605
1603
1606
1604
\LMHash{}%
1607
1605
\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,
1609
1607
then the invocation of the implicit getter of \id{} evaluates to
1610
1608
the object stored in \id.
1611
1609
\EndCase
1612
1610
1613
1611
\LMHash{}%
1614
1612
\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{}
1616
1614
and an initializing expression $e$,
1617
1615
then the first invocation of the implicit getter of \id{}
1618
1616
will evaluate $e$ to an object $o$, store $o$ in \id{},
@@ -1639,7 +1637,7 @@ \subsection{Evaluation of Implicit Variable Getters}
1639
1637
1640
1638
\LMHash{}%
1641
1639
\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
1643
1641
which has the modifier \LATE{} and no initializing expression.
1644
1642
Assume that the corresponding setter has been executed and did not throw.
1645
1643
In this case, an invocation of the implicit getter of \id{}
@@ -1650,49 +1648,48 @@ \subsection{Evaluation of Implicit Variable Getters}
1650
1648
1651
1649
\LMHash{}%
1652
1650
\Case{Static variable}
1653
- If $d$ is a static variable
1651
+ If $d$ declares a static variable
1654
1652
(\commentary{that is, a library variable or a class variable}),
1655
1653
the implicit getter method of \id{} executes as follows:
1656
1654
1657
1655
\begin{itemize}
1658
1656
\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
+ }
1684
1682
\item \emph{Constant variable.}
1685
1683
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$;}.
1690
1686
the result of the getter is the value of the constant expression $e$.
1691
1687
\commentary{%
1692
1688
Note that a constant expression cannot depend on itself,
1693
1689
so no cyclic references can occur.%
1694
1690
}
1695
1691
\item \emph{Variable without an initializer.}
1692
+
1696
1693
The result of executing the getter method is the object stored in $v$.
1697
1694
\commentary{This may be the initial value, that is, the null object.}
1698
1695
\end{itemize}
0 commit comments