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