Skip to content

Commit cfb1643

Browse files
authored
Merge pull request #3155 from ntrel/expr-def
[expression.dd] Improve formatting for *Definitions and Terms* Signed-off-by: Mike Parker <aldacron@gmail.com> Merged-on-behalf-of: Dennis <dkorpel@users.noreply.github.com>
2 parents 52ca9eb + 78ffa02 commit cfb1643

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

spec/expression.dd

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,34 @@ The syntax, order of evaluation, and semantics of expressions are as follows.)
2121

2222
$(H2 $(LNAME2 definitions-and-terms, Definitions and Terms))
2323

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
2527
$(I expr), the full expression of $(I expr) is defined as follows. If $(I expr) parses as a
2628
subexpression of another expression $(I expr$(SUBSCRIPT 1)), then the full expression of $(I expr) is the
2729
full expression of $(I expr$(SUBSCRIPT 1)). Otherwise, $(I expr) is its own full expression.)
2830

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+
---
3036

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
3238
full expression of `f() + g()` because the latter is not parsed as a subexpression.)
3339

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
3647
to `return`. This is because the parent of `x + f()` has function literal type, not expression type.)
3748

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*:)
4052
$(OL
4153
$(LI `this` inside `struct` and `union` member functions;)
4254
$(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
6274
$(LI `cast()` and `cast(`$(I qualifier list)`)` when applied to an lvalue.)
6375
)))
6476

65-
$(DDOC_ANCHOR define-rvalue)$(P $(B Definition) ($(DOUBLEQUOTE Rvalue)): Expressions that are not
66-
lvalues are rvalues.)
77+
$(H3 $(LNAME2 .define-rvalue, Rvalue))
6778

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__`,
6980
`enum` values, and the result of expressions not defined as lvalues above.)
7081

7182
$(P The built-in address-of operator (unary `&`) may only be applied to lvalues.)
7283

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))
7885

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.
8299

83100
$(H2 $(LNAME2 order-of-evaluation, Order Of Evaluation))
84101

0 commit comments

Comments
 (0)