summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2006-08-09 10:06:28 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2006-08-09 10:06:28 (GMT)
commit99218e86bcf6d184ccf51155c312d298a5d82b07 (patch)
treee3746121f114a149427f88ebfe84850a5ae43702 /doc
parenta15358050ba135ab39f8fa94adbd1584fb657ffa (diff)
downloadtcl-99218e86bcf6d184ccf51155c312d298a5d82b07.zip
tcl-99218e86bcf6d184ccf51155c312d298a5d82b07.tar.gz
tcl-99218e86bcf6d184ccf51155c312d298a5d82b07.tar.bz2
Make [expr] use in examples more idiomatic [Bug 1526581]
Diffstat (limited to 'doc')
-rw-r--r--doc/ParseCmd.38
-rw-r--r--doc/expr.n20
-rw-r--r--doc/set.n4
-rw-r--r--doc/subst.n8
-rw-r--r--doc/switch.n16
-rw-r--r--doc/tclvars.n4
6 files changed, 30 insertions, 30 deletions
diff --git a/doc/ParseCmd.3 b/doc/ParseCmd.3
index 921ba22..b49f839 100644
--- a/doc/ParseCmd.3
+++ b/doc/ParseCmd.3
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: ParseCmd.3,v 1.22 2005/09/15 23:13:32 msofer Exp $
+'\" RCS: @(#) $Id: ParseCmd.3,v 1.23 2006/08/09 10:06:28 dkf Exp $
'\"
.so man.macros
.TH Tcl_ParseCommand 3 8.3 Tcl "Tcl Library Procedures"
@@ -135,7 +135,7 @@ an error message is left in \fIinterp\fR's result,
and no information is left at \fI*parsePtr\fR or \fI*termPtr\fR.
.PP
\fBTcl_ParseQuotedString\fR parses a double-quoted string such as
-\fB"sum is [expr $a+$b]"\fR
+\fB"sum is [expr {$a+$b}]"\fR
from the beginning of the argument \fIstart\fR.
The first character of \fIstart\fR must be \fB"\fR.
If the double-quoted string was parsed successfully,
@@ -151,7 +151,7 @@ an error message is left in \fIinterp\fR's result,
and no information is left at \fI*parsePtr\fR or \fI*termPtr\fR.
.PP
\fBTcl_ParseVarName\fR parses a Tcl variable reference such as
-\fB$abc\fR or \fB$x([expr $index + 1])\fR from the beginning of its
+\fB$abc\fR or \fB$x([expr {$index + 1}])\fR from the beginning of its
\fIstart\fR argument.
The first character of \fIstart\fR must be \fB$\fR.
If a variable name was parsed successfully, \fBTcl_ParseVarName\fR
@@ -163,7 +163,7 @@ error message is left in \fIinterp\fR's result (if \fIinterp\fR isn't
NULL), and no information is left at \fI*parsePtr\fR.
.PP
\fBTcl_ParseVar\fR parse a Tcl variable reference such as \fB$abc\fR
-or \fB$x([expr $index + 1])\fR from the beginning of its \fIstart\fR
+or \fB$x([expr {$index + 1}])\fR from the beginning of its \fIstart\fR
argument. The first character of \fIstart\fR must be \fB$\fR. If
the variable name is parsed successfully, \fBTcl_ParseVar\fR returns a
pointer to the string value of the variable. If an error occurs while
diff --git a/doc/expr.n b/doc/expr.n
index 880ab0e..d84f384 100644
--- a/doc/expr.n
+++ b/doc/expr.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: expr.n,v 1.22 2006/04/26 04:41:10 dgp Exp $
+'\" RCS: @(#) $Id: expr.n,v 1.23 2006/08/09 10:06:28 dkf Exp $
'\"
.so man.macros
.TH expr n 8.5 Tcl "Tcl Built-In Commands"
@@ -108,10 +108,10 @@ Then the command on the left side of each of the lines below
will produce the value on the right side of the line:
.CS
.ta 6c
-\fBexpr 3.1 + $a 6.1
-expr 2 + "$a.$b" 5.6
-expr 4*[llength "6 2"] 8
-expr {{word one} < "word $a"} 0\fR
+\fBexpr\fR 3.1 + $a \fI6.1\fR
+\fBexpr\fR 2 + "$a.$b" \fI5.6\fR
+\fBexpr\fR 4*[llength "6 2"] \fI8\fR
+\fBexpr\fR {{word one} < "word $a"} \fI0\fR
.CE
.SS OPERATORS
.PP
@@ -199,7 +199,7 @@ of the \fBpow\fR function (after any type conversions.)
All of the binary operators group left-to-right within the same
precedence level. For example, the command
.CS
-\fBexpr 4*2 < 7\fR
+\fBexpr\fR {4*2 < 7}
.CE
returns 0.
.PP
@@ -266,19 +266,19 @@ For arithmetic computations, integers are used until some
floating-point number is introduced, after which floating-point is used.
For example,
.CS
-\fBexpr 5 / 4\fR
+\fBexpr\fR {5 / 4}
.CE
returns 1, while
.CS
-\fBexpr 5 / 4.0\fR
-\fBexpr 5 / ( [string length "abcd"] + 0.0 )\fR
+\fBexpr\fR {5 / 4.0}
+\fBexpr\fR {5 / ( [string length "abcd"] + 0.0 )}
.CE
both return 1.25.
Floating-point values are always returned with a ``\fB.\fR''
or an \fBe\fR so that they will not look like integer values. For
example,
.CS
-\fBexpr 20.0/5.0\fR
+\fBexpr\fR {20.0/5.0}
.CE
returns \fB4.0\fR, not \fB4\fR.
.SS "STRING OPERATIONS"
diff --git a/doc/set.n b/doc/set.n
index 0c947ad..91e9c71 100644
--- a/doc/set.n
+++ b/doc/set.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: set.n,v 1.6 2004/10/27 14:24:37 dkf Exp $
+'\" RCS: @(#) $Id: set.n,v 1.7 2006/08/09 10:06:28 dkf Exp $
'\"
.so man.macros
.TH set n "" Tcl "Tcl Built-In Commands"
@@ -44,7 +44,7 @@ unless \fIvarName\fR was declared to resolve differently through one of the
.SH EXAMPLES
Store a random number in the variable \fIr\fR:
.CS
-\fBset\fR r [expr rand()]
+\fBset\fR r [expr {rand()}]
.CE
.PP
Store a short message in an array element:
diff --git a/doc/subst.n b/doc/subst.n
index 46572a8..02f621c 100644
--- a/doc/subst.n
+++ b/doc/subst.n
@@ -6,7 +6,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: subst.n,v 1.8 2005/05/10 18:34:03 kennykb Exp $
+'\" RCS: @(#) $Id: subst.n,v 1.9 2006/08/09 10:06:28 dkf Exp $
'\"
.so man.macros
.TH subst n 7.4 Tcl "Tcl Built-In Commands"
@@ -100,17 +100,17 @@ when processing text using \fIsubst\fR. For example, the script
.CE
returns ``\fBabc,\fR'', not ``\fBabc,,def\fR'' and the script
.CS
-\fBsubst\fR {abc,[continue;expr 1+2],def}
+\fBsubst\fR {abc,[continue;expr {1+2}],def}
.CE
returns ``\fBabc,,def\fR'', not ``\fBabc,3,def\fR''.
.PP
Other exceptional return codes substitute the returned value
.CS
-\fBsubst\fR {abc,[return foo;expr 1+2],def}
+\fBsubst\fR {abc,[return foo;expr {1+2}],def}
.CE
returns ``\fBabc,foo,def\fR'', not ``\fBabc,3,def\fR'' and
.CS
-\fBsubst\fR {abc,[return -code 10 foo;expr 1+2],def}
+\fBsubst\fR {abc,[return -code 10 foo;expr {1+2}],def}
.CE
also returns ``\fBabc,foo,def\fR'', not ``\fBabc,3,def\fR''.
diff --git a/doc/switch.n b/doc/switch.n
index 83103cb..bcab863 100644
--- a/doc/switch.n
+++ b/doc/switch.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: switch.n,v 1.9 2005/06/01 11:00:33 dkf Exp $
+'\" RCS: @(#) $Id: switch.n,v 1.10 2006/08/09 10:06:28 dkf Exp $
'\"
.so man.macros
.TH switch n 8.5 Tcl "Tcl Built-In Commands"
@@ -117,7 +117,7 @@ The \fBswitch\fR command can match against variables and not just
literals, as shown here (the result is \fI2\fR):
.CS
set foo "abc"
-\fBswitch\fR abc a \- b {expr 1} $foo {expr 2} default {expr 3}
+\fBswitch\fR abc a \- b {expr {1}} $foo {expr {2}} default {expr {3}}
.CE
.PP
Using glob matching and the fall-through body is an alternative to
@@ -126,9 +126,9 @@ writing regular expressions with alternations, as can be seen here
.CS
\fBswitch\fR \-glob aaab {
a*b \-
- b {expr 1}
- a* {expr 2}
- default {expr 3}
+ b {expr {1}}
+ a* {expr {2}}
+ default {expr {3}}
}
.CE
.PP
@@ -139,13 +139,13 @@ last) is taken. This example has a result of \fI3\fR:
a \-
b {
# Correct Comment Placement
- expr 1
+ expr {1}
}
c {
- expr 2
+ expr {2}
}
default {
- expr 3
+ expr {3}
}
}
.CE
diff --git a/doc/tclvars.n b/doc/tclvars.n
index 0c0debb..eaa0dc1 100644
--- a/doc/tclvars.n
+++ b/doc/tclvars.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: tclvars.n,v 1.24 2006/04/18 18:05:47 dgp Exp $
+'\" RCS: @(#) $Id: tclvars.n,v 1.25 2006/08/09 10:06:28 dkf Exp $
'\"
.so man.macros
.TH tclvars n 8.0 Tcl "Tcl Built-In Commands"
@@ -263,7 +263,7 @@ binary number.
double-precision values to be converted to strings and back to
binary with no loss of information. However, using 17 digits prevents
any rounding, which produces longer, less intuitive results. For example,
-\fBexpr 1.4\fR returns 1.3999999999999999 with \fBtcl_precision\fR
+\fBexpr {1.4}\fR returns 1.3999999999999999 with \fBtcl_precision\fR
set to 17, vs. 1.4 if \fBtcl_precision\fR is 12.
.RE
.PP