@@ -14,22 +14,34 @@ The syntax, order of evaluation, and semantics of expressions are as follows.)
14
14
15
15
$(H2 $(LNAME2 definitions-and-terms, Definitions and Terms))
16
16
17
- $(DDOC_ANCHOR define-full-expression)$(P $(B Definition) ($(DOUBLEQUOTE Full expression)): For any expression
17
+ $(H3 $(LNAME2 define-full-expression, Full Expression))
18
+
19
+ $(P For any expression
18
20
$(I expr), the full expression of $(I expr) is defined as follows. If $(I expr) parses as a
19
21
subexpression of another expression $(I expr$(SUBSCRIPT 1)), then the full expression of $(I expr) is the
20
22
full expression of $(I expr$(SUBSCRIPT 1)). Otherwise, $(I expr) is its own full expression.)
21
23
22
- $(P Each expression has a unique full expression.)
24
+ $(P Each expression has a unique full expression. Example:)
25
+
26
+ ---
27
+ return f() + g() * 2;
28
+ ---
23
29
24
- $(P Example: in the statement `return f() + g() * 2;`, the full expression of `g() * 2` is `f() + g() * 2`, but not the
30
+ $(P The full expression of `g() * 2` above is `f() + g() * 2`, but not the
25
31
full expression of `f() + g()` because the latter is not parsed as a subexpression.)
26
32
27
- $(P Note: Although the definition is straightforward, a few subtleties exist related to function literals. In the
28
- statement `return (() => x + f())() * g();`, the full expression of `f()` is `x + f()`, not the expression passed
33
+ $(P Note: Although the definition is straightforward, a few subtleties exist related to function literals:)
34
+
35
+ ---
36
+ return (() => x + f())() * g();
37
+ ---
38
+
39
+ $(P The full expression of `f()` above is `x + f()`, not the expression passed
29
40
to `return`. This is because the parent of `x + f()` has function literal type, not expression type.)
30
41
31
- $(DDOC_ANCHOR define-lvalue)$(P $(B Definition) ($(DOUBLEQUOTE Lvalue)): The following expressions, and no
32
- others, are called lvalue expressions or lvalues:)
42
+ $(H3 $(LNAME2 define-lvalue, Lvalue))
43
+
44
+ $(P The following expressions, and no others, are called *lvalue expressions* or *lvalues*:)
33
45
$(OL
34
46
$(LI `this` inside `struct` and `union` member functions;)
35
47
$(LI a variable or the result of the $(I DotIdentifier) grammatical construct `.` (left side may be
@@ -55,23 +67,28 @@ $(LI `cast(U)` expressions applied to lvalues of type `T` when `T*` is implicitl
55
67
$(LI `cast()` and `cast(`$(I qualifier list)`)` when applied to an lvalue.)
56
68
)))
57
69
58
- $(DDOC_ANCHOR define-rvalue)$(P $(B Definition) ($(DOUBLEQUOTE Rvalue)): Expressions that are not
59
- lvalues are rvalues.)
70
+ $(H3 $(LNAME2 define-rvalue, Rvalue))
60
71
61
- $(P Note: Rvalues include all literals, special value keywords such as `__FILE__` and `__LINE__`,
72
+ $(P Expressions that are not lvalues are *rvalues*. Rvalues include all literals, special value keywords such as `__FILE__` and `__LINE__`,
62
73
`enum` values, and the result of expressions not defined as lvalues above.)
63
74
64
75
$(P The built-in address-of operator (unary `&`) may only be applied to lvalues.)
65
76
66
- $(DDOC_ANCHOR define-smallest-short-circuit)$(P $(B Definition) ($(DOUBLEQUOTE Smallest
67
- short-circuit expression)): Given an expression $(I expr) that is a subexpression of a full
68
- expression $(I fullexpr), the smallest short-circuit expression, if any, is the shortest
69
- subexpression $(I scexpr) of $(I fullexpr) that is an $(GLINK AndAndExpression) (`&&`) or an
70
- $(GLINK OrOrExpression) (`||`), such that $(I expr) is a subexpression of $(I scexpr).)
77
+ $(H3 $(LNAME2 define-smallest-short-circuit, Smallest Short-Circuit Expression))
71
78
72
- Example: in the expression `((f() * 2 && g()) + 1) || h()`, the smallest short-circuit expression
73
- of the subexpression `f() * 2` is `f() * 2 && g()`. In the expression `(f() && g()) + h()`, the
74
- subexpression `h()` has no smallest short-circuit expression.
79
+ $(P Given an expression $(I expr) that is a subexpression of a full
80
+ expression $(I fullexpr), the *smallest short-circuit expression*, if any, is the shortest
81
+ subexpression $(I scexpr) of $(I fullexpr) that is an $(GLINK AndAndExpression) (`&&`) or an
82
+ $(GLINK OrOrExpression) (`||`), such that $(I expr) is a subexpression of $(I scexpr). Example:)
83
+ ---
84
+ ((f() * 2 && g()) + 1) || h()
85
+ ---
86
+ The smallest short-circuit expression
87
+ of the subexpression `f() * 2` above is `f() * 2 && g()`. Example:
88
+ ---
89
+ (f() && g()) + h()
90
+ ---
91
+ The subexpression `h()` above has no smallest short-circuit expression.
75
92
76
93
$(H2 $(LNAME2 order-of-evaluation, Order Of Evaluation))
77
94
0 commit comments