Skip to content

Commit e2f0e87

Browse files
ntreldlang-bot
authored andcommitted
[spec/expression] Tweak increment/decrement ops
Use tables for lowering. Remove unnecessary `T` in lambda.
1 parent 4eaaf74 commit e2f0e87

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

spec/expression.dd

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,27 @@ The subexpression `h()` above has no smallest short-circuit expression.
100100
$(H2 $(LNAME2 order-of-evaluation, Order Of Evaluation))
101101

102102
$(P Built-in prefix unary expressions `++` and `--` are evaluated as if lowered (rewritten) to
103-
assignments as follows: `++expr` becomes `((expr) += 1)`, and `--expr` becomes `((expr) -= 1)`.
103+
$(RELATIVE_LINK2 assignment_operator_expressions, assignments) as follows:)
104+
105+
$(TABLE
106+
$(THEAD Expression, Equivalent)
107+
$(TROW `++expr`, `((expr) += 1)`)
108+
$(TROW `--expr`, `((expr) -= 1)`)
109+
)
110+
$(P
104111
Therefore, the result of prefix `++` and `--` is the lvalue after the side effect has been
105112
effected.)
106113

107114
$(P Built-in postfix unary expressions `++` and `--` are evaluated as if lowered (rewritten) to
108115
$(DDSUBLINK spec/expression, function_literals, lambda)
109-
invocations as follows: `expr++` becomes `(ref T x){auto t = x; ++x; return t;}(expr)`, and
110-
`expr--` becomes `(ref T x){auto t = x; --x; return t;}(expr)`. Therefore, the result of postfix
116+
invocations as follows:)
117+
118+
$(TABLE
119+
$(THEAD Expression, Equivalent)
120+
$(TROW `expr++`, `(ref x){auto t = x; ++x; return t;}(expr)`)
121+
$(TROW `expr--`, `(ref x){auto t = x; --x; return t;}(expr)`)
122+
)
123+
$(P Therefore, the result of postfix
111124
`++` and `--` is an rvalue just before the side effect has been effected.)
112125

113126
$(P Binary expressions except for $(GLINK AssignExpression), $(GLINK OrOrExpression), and

0 commit comments

Comments
 (0)