diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-10-29 01:42:18 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-10-29 01:42:18 (GMT) |
commit | 71f78ed1de764f208d95b703744c7682d448c3e3 (patch) | |
tree | 8e72d3dd4068fc22320de66ab7145fa75119f54c /doc/expr.n | |
parent | ccacc920f9cd610a9a9d8e800f623c20bf43a702 (diff) | |
download | tcl-71f78ed1de764f208d95b703744c7682d448c3e3.zip tcl-71f78ed1de764f208d95b703744c7682d448c3e3.tar.gz tcl-71f78ed1de764f208d95b703744c7682d448c3e3.tar.bz2 |
Next stage of doing GOOBE improvements to documentation now that the html generation works
Diffstat (limited to 'doc/expr.n')
-rw-r--r-- | doc/expr.n | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -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.27 2007/10/26 20:11:52 dgp Exp $ +'\" RCS: @(#) $Id: expr.n,v 1.28 2007/10/29 01:42:18 dkf Exp $ '\" .so man.macros .TH expr n 8.5 Tcl "Tcl Built-In Commands" @@ -203,9 +203,9 @@ precedence level. For example, the command .CE returns 0. .PP -The \fB&&\fR, \fB||\fR, and \fB?:\fR operators have ``lazy -evaluation'', just as in C, -which means that operands are not evaluated if they are +The \fB&&\fR, \fB||\fR, and \fB?:\fR operators have +.QW "lazy evaluation" , +just as in C, which means that operands are not evaluated if they are not needed to determine the outcome. For example, in the command .CS \fBexpr {$v ? [a] : [b]}\fR @@ -274,9 +274,11 @@ returns 1, while \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, +Floating-point values are always returned with a +.QW \fB.\fR +or an +.QW \fBe\fR +so that they will not look like integer values. For example, .CS \fBexpr\fR {20.0/5.0} .CE @@ -302,9 +304,9 @@ both return 1. The first comparison is done using integer comparison, and the second is done using string comparison after the second operand is converted to the string \fB18\fR. Because of Tcl's tendency to treat values as numbers whenever -possible, it isn't generally a good idea to use operators like \fB==\fR +possible, it is not generally a good idea to use operators like \fB==\fR when you really want string comparison and the values of the -operands could be arbitrary; it's better in these cases to use +operands could be arbitrary; it is better in these cases to use the \fBeq\fR or \fBne\fR operators, or the \fBstring\fR command instead. .SH "PERFORMANCE CONSIDERATIONS" .PP @@ -328,7 +330,7 @@ then the \fBexpr\fR command will evaluate the expression \fB$a + 2*4\fR. Most expressions do not require a second round of substitutions. Either they are enclosed in braces or, if not, their variable and command substitutions yield numbers or strings -that don't themselves require substitutions. +that do not themselves require substitutions. However, because a few unbraced expressions need two rounds of substitutions, the bytecode compiler must emit @@ -338,8 +340,9 @@ unbraced expressions that contain command substitutions. These expressions must be implemented by generating new code each time the expression is executed. .SH EXAMPLES -Define a procedure that computes an "interesting" mathematical -function: +Define a procedure that computes an +.QW interesting +mathematical function: .CS proc tcl::mathfunc::calc {x y} { \fBexpr\fR { ($x**2 - $y**2) / exp($x**2 + $y**2) } |