Skip to content

Commit 5a8e617

Browse files
committed
[expr.log.and],[expr.log.or] improve wording symmetry and quality
1 parent 24659bd commit 5a8e617

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

source/expressions.tex

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6810,20 +6810,21 @@
68106810
\end{bnf}
68116811

68126812
\pnum
6813-
The \tcode{\&\&} operator groups left-to-right. The operands are both
6814-
contextually converted to \keyword{bool}\iref{conv}.
6815-
The
6816-
result is \keyword{true} if both operands are \keyword{true} and
6817-
\keyword{false} otherwise. Unlike \tcode{\&}, \tcode{\&\&} guarantees
6818-
left-to-right evaluation: the second operand is not evaluated if the
6819-
first operand is \keyword{false}.
6813+
The \tcode{\&\&} operator groups left-to-right.
6814+
The operands are both contextually converted to \keyword{bool}\iref{conv}.
6815+
The result is
6816+
\keyword{true} if both operands are \keyword{true} and
6817+
\keyword{false} otherwise.
68206818

68216819
\pnum
6822-
The result is a \tcode{bool}.
68236820
\indextext{operator!side effects and logical AND}%
6824-
If the second expression is evaluated,
6825-
the first expression is sequenced before
6826-
the second expression\iref{intro.execution}.
6821+
The right operand is not evaluated if the left operand evaluates to \keyword{false}.
6822+
The evaluation of the left operand is sequenced before\iref{intro.execution}
6823+
the evaluation (if any) of the right operand.
6824+
\begin{note}
6825+
The former behavior is sometimes called "short-circuiting".
6826+
The \tcode{&} operator guarantees neither short-circuiting nor left-to-right evaluation.
6827+
\end{note}
68276828

68286829
\rSec2[expr.log.or]{Logical OR operator}%
68296830
\indextext{expression!logical OR}%
@@ -6837,20 +6838,21 @@
68376838
\end{bnf}
68386839

68396840
\pnum
6840-
The \tcode{||} operator groups left-to-right. The operands are both
6841-
contextually converted to \keyword{bool}\iref{conv}.
6841+
The \tcode{||} operator groups left-to-right.
6842+
The operands are both contextually converted to \keyword{bool}\iref{conv}.
68426843
The result is
68436844
\keyword{true} if either of its operands is \keyword{true}, and
6844-
\keyword{false} otherwise. Unlike \tcode{|}, \tcode{||} guarantees
6845-
left-to-right evaluation; moreover, the second operand is not evaluated
6846-
if the first operand evaluates to \keyword{true}.
6845+
\keyword{false} otherwise.
68476846

68486847
\pnum
6849-
The result is a \keyword{bool}.
68506848
\indextext{operator!side effects and logical OR}%
6851-
If the second expression is evaluated,
6852-
the first expression is sequenced before
6853-
the second expression\iref{intro.execution}.
6849+
The right operand is not evaluated if the left operand evaluates to \keyword{true}.
6850+
The evaluation of the left operand is sequenced before\iref{intro.execution}
6851+
the evaluation (if any) of the right operand.
6852+
\begin{note}
6853+
The former behavior is sometimes called "short-circuiting".
6854+
The \tcode{|} operator guarantees neither short-circuiting nor left-to-right evaluation.
6855+
\end{note}
68546856

68556857
\rSec2[expr.cond]{Conditional operator}%
68566858
\indextext{expression!conditional operator}%

0 commit comments

Comments
 (0)