Skip to content

Commit aff97fa

Browse files
committed
[expression.dd] Improve formatting for *Definitions and Terms*
1 parent a47558e commit aff97fa

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
@@ -14,22 +14,34 @@ The syntax, order of evaluation, and semantics of expressions are as follows.)
1414

1515
$(H2 $(LNAME2 definitions-and-terms, Definitions and Terms))
1616

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

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

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

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

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*:)
3345
$(OL
3446
$(LI `this` inside `struct` and `union` member functions;)
3547
$(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
5567
$(LI `cast()` and `cast(`$(I qualifier list)`)` when applied to an lvalue.)
5668
)))
5769

58-
$(DDOC_ANCHOR define-rvalue)$(P $(B Definition) ($(DOUBLEQUOTE Rvalue)): Expressions that are not
59-
lvalues are rvalues.)
70+
$(H3 $(LNAME2 define-rvalue, Rvalue))
6071

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

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

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

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

7693
$(H2 $(LNAME2 order-of-evaluation, Order Of Evaluation))
7794

0 commit comments

Comments
 (0)