Skip to content

Commit 5938abb

Browse files
committed
More precise terminology on evaluation order
I've italicized "operand" showing that it is a definition. I didn't actually remember that being added to the reference, so I basically tried to redefine it in the previous commit. I don't like the term, but since it's already there, I'll just use it. I also put in a note saying that operator precedence determines the operands of an expression. That section could probably be written in a style that better expresses that perspective, but I'm trying to keep this change minimal. I also stated that the evaluation of operands is done prior to applying the effect. This goes in line with the beginning of the chapter with what the meaning of an expression. Note also that this only describes the default. Expressions that deviate from the default already should describe their evaluation order.
1 parent d024cf7 commit 5938abb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/expressions.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
An expression may have two roles: it always produces a *value*, and it may have
4646
*effects* (otherwise known as "side effects"). An expression *evaluates to* a
4747
value, and has effects during *evaluation*. Many expressions contain
48-
sub-expressions (operands). The meaning of each kind of expression dictates
49-
several things:
48+
sub-expressions, called the *operands* of the expression. The meaning of each
49+
kind of expression dictates several things:
5050

5151
* Whether or not to evaluate the sub-expressions when evaluating the expression
5252
* The order in which to evaluate the sub-expressions
@@ -85,11 +85,14 @@ in the order given by their associativity.
8585
| `=` `+=` `-=` `*=` `/=` `%=` <br> `&=` <code>&#124;=</code> `^=` `<<=` `>>=` | right to left |
8686
| `return` `break` closures | |
8787

88-
## Evaluation order
88+
## Evaluation order of operands
8989

90-
Most expressions include subexpressions. Unless otherwise stated on the
91-
expression's page, evaluation of these inner expressions is left to right as
92-
written in the source code.
90+
Unless otherwise stated on the expression's page, evaluation of the operands of
91+
an expression is done before applying the effect of the expression. The operands
92+
are executed left to right as written in the source code.
93+
94+
> **Note**: Which subexpressions are the operands of an expression is
95+
> determined by expression precedence as per the previous section.
9396
9497
For example, the two `next` method calls will always be called in the same
9598
order:

0 commit comments

Comments
 (0)