|
41 | 41 | % version of the language which will actually be specified by the next stable |
42 | 42 | % release of this document. |
43 | 43 | % |
| 44 | +% Apr 2025 |
| 45 | +% - Change the rules about constants to be more consistent: Every constant |
| 46 | +% expression is also a potentially constant expression. Also, eliminate |
| 47 | +% redundancies in the rules about constant collection literals and constant |
| 48 | +% object expressions (they are now defined just once, outside 'Constants'). |
| 49 | +% |
44 | 50 | % Sep 2024 |
45 | 51 | % - Clarify the extension applicability rule to explicitly state that it |
46 | 52 | % is concerned with an instance member with the same basename, not a |
@@ -8653,48 +8659,20 @@ \subsection{Constants} |
8653 | 8659 | is a potentially constant expression. |
8654 | 8660 |
|
8655 | 8661 | \item |
8656 | | - A constant object expression (\ref{const}), |
8657 | | - \code{\CONST{} $C$<$T_1,\ \ldots,\ T_k$>(\metavar{arguments})} or |
8658 | | - \code{\CONST{} $C$<$T_1,\ \ldots,\ T_k$>.\id(\metavar{arguments})}, |
8659 | | - or either expression without the leading \CONST{} that occurs in |
8660 | | - a constant context, |
8661 | | - is a potentially constant expression. |
8662 | | - It is further a constant expression if the invocation evaluates to an object. |
8663 | | - % \ref{const} requires each actual argument to be a constant expression, |
8664 | | - % but here we also catch errors during evaluation, e.g., `C(1, 0)` where |
8665 | | - % `C(double x, double y): z = x / y;`. |
8666 | | - It is a compile-time error if a constant object expression is |
8667 | | - not a constant expression (\ref{const}). |
| 8662 | + A constant object expression (\ref{const}) |
| 8663 | + is a potentially constant and constant expression. |
8668 | 8664 |
|
8669 | 8665 | \item |
8670 | | - A constant list literal (\ref{lists}), |
8671 | | - \code{\CONST{} <$T$>[$e_1$, \ldots, $e_n$]}, or |
8672 | | - \code{<$T$>[$e_1$, \ldots, $e_n$]} |
8673 | | - that occurs in a constant context, |
8674 | | - is a potentially constant expression if $T$ is a constant type expression, |
8675 | | - and $e_1$, \ldots{} , $e_n$ are constant expressions. |
8676 | | - It is further a constant expression |
8677 | | - if the list literal evaluates to an object. |
| 8666 | + A constant list literal (\ref{lists}) |
| 8667 | + is a potentially constant and constant expression. |
8678 | 8668 |
|
8679 | 8669 | \item |
8680 | | - A constant set literal (\ref{sets}), |
8681 | | - \code{\CONST{} <$T$>\{$e_1$, \ldots, $e_n$\}}, or |
8682 | | - \code{<$T$>\{$e_1$, \ldots, $e_n$\}} |
8683 | | - that occurs in a constant context, |
8684 | | - is a potentially constant expression |
8685 | | - if $T$ is a constant type expression, |
8686 | | - and $e_1$, \ldots{} , $e_n$ are constant expressions. |
8687 | | - It is further a constant expression |
8688 | | - if the set literal evaluates to an object. |
| 8670 | + A constant set literal (\ref{sets}) |
| 8671 | + is a potentially constant and constant expression. |
8689 | 8672 |
|
8690 | 8673 | \item |
8691 | | - A constant map literal (\ref{maps}), |
8692 | | - \code{\CONST{} <$K$, $V$>\{$k_1$: $v_1$, \ldots, $k_n$: $v_n$\}}, or |
8693 | | - \code{<$K$, $V$>\{$k_1$: $v_1$, \ldots, $k_n$: $v_n$\}} |
8694 | | - that occurs in a constant context, |
8695 | | - is a potentially constant expression. |
8696 | | - It is further a constant expression |
8697 | | - if the map literal evaluates to an object. |
| 8674 | + A constant map literal (\ref{maps}) |
| 8675 | + is a potentially constant and constant expression. |
8698 | 8676 |
|
8699 | 8677 | \item |
8700 | 8678 | A parenthesized expression \code{($e$)} is |
@@ -8813,7 +8791,7 @@ \subsection{Constants} |
8813 | 8791 | \item An expression of the form \code{$e_1$\,?\,$e_2$\,:\,$e_3$} |
8814 | 8792 | is potentially constant if $e_1$, $e_2$, and $e_3$ |
8815 | 8793 | are all potentially constant expressions. |
8816 | | - It is constant if $e_1$ is a constant expression and either |
| 8794 | + It is further constant if $e_1$ is a constant expression and either |
8817 | 8795 | \begin{enumerate} |
8818 | 8796 | \item $e_1$ evaluates to \TRUE{} and $e_2$ is a constant expression, or |
8819 | 8797 | \item $e_1$ evaluates to \FALSE{} and $e_3$ is a constant expression. |
|
0 commit comments