[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 18/50: [docs]: Tweak discussion of numeric expressions.
From: |
G. Branden Robinson |
Subject: |
[groff] 18/50: [docs]: Tweak discussion of numeric expressions. |
Date: |
Sat, 21 May 2022 12:17:25 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 581f1bc69afdcf0720d284a207e61554aa52891c
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue May 17 18:27:08 2022 -0500
[docs]: Tweak discussion of numeric expressions.
When discussing the logical complementation operator, there is no need
to suggest that anything special is required to test for truth; it is
the test for falsity that requires a workaround. Recast explanation and
update example.
---
doc/groff.texi | 21 ++++++++++++---------
man/groff.7.man | 11 +++++------
2 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/doc/groff.texi b/doc/groff.texi
index e4b5972f..f6cb1246 100644
--- a/doc/groff.texi
+++ b/doc/groff.texi
@@ -5903,15 +5903,18 @@ We can operate on truth values with the the logical
operators @code{&}
@cindex logical not, limitation in expression
@cindex expression, limitation of logical not in
A logical complementation (``not'') operator, @code{!}, works only
-within @code{if}, @code{ie}, and @code{while} requests. Furthermore,
-@code{!} is recognized only at the beginning of a numeric expression not
-contained by another numeric expression. In other words, it must be the
-``outermost'' operator. Attempting to include it elsewhere in the
-expression produces a warning in the @samp{number} category
-(@pxref{Debugging}), and its expression evaluates false. This
+within @code{if}, @code{ie}, and @code{while} requests.
+@c This is worded to avoid implying that the operator doesn't apply
+@c to conditional expressions in general, albeit without mentioning them
+@c because they're out of scope.
+Furthermore, @code{!} is recognized only at the beginning of a numeric
+expression not contained by another numeric expression. In other words,
+it must be the ``outermost'' operator. Attempting to include it
+elsewhere in the expression produces a warning in the @samp{number}
+category (@pxref{Debugging}), and its expression evaluates false. This
unfortunate limitation maintains compatibility with @acronym{AT&T}
-@code{troff}. You can work around it by comparing numeric expressions
-to the canonical truth values @samp{0} and @samp{1}.
+@code{troff}. You can test a numeric expression for falsity by
+comparing it to a false value.
@Example
.nr X 1
@@ -5920,7 +5923,7 @@ to the canonical truth values @samp{0} and @samp{1}.
.if (\n[X])&(!\n[Y]) .nop A: X is true, Y is false
.
.\" Use this construct instead.
-.if (\n[X])&(\n[Y]=0) .nop B: X is true, Y is false
+.if (\n[X])&(\n[Y]<=0) .nop B: X is true, Y is false
@error{} warning: expected numeric expression, got '!'
@result{} B: X is true, Y is false
@endExample
diff --git a/man/groff.7.man b/man/groff.7.man
index dcfcfdbb..49122213 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -974,7 +974,9 @@ and
.RB \[lq] while \[rq]
requests.
.
-.
+.\" This is worded to avoid implying that the operator doesn't apply to
+.\" conditional expressions in general, albeit without mentioning them
+.\" because they're out of scope.
Furthermore,
.B !\&
is recognized only at the beginning of a numeric expression not
@@ -992,11 +994,8 @@ and its expression evaluates false.
This unfortunate limitation maintains compatibility with AT&T
.IR troff .\" AT&T
.
-You can work around it by comparing numeric expressions to the canonical
-truth values
-.B 0
-and
-.BR 1 .
+You can test a numeric expression for falsity by comparing it to a false
+value.
.
.
.P
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 18/50: [docs]: Tweak discussion of numeric expressions.,
G. Branden Robinson <=