diff options
author | hobbs <hobbs> | 2000-05-09 00:00:34 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2000-05-09 00:00:34 (GMT) |
commit | 427c904742d9d5aec8068fce38a28be9ae65af08 (patch) | |
tree | 1e3bab60e826e937b67fa7d70d97f4f352fe315a /doc/expr.n | |
parent | 9f7b9b72befea46deb71233146973eea88223af0 (diff) | |
download | tcl-427c904742d9d5aec8068fce38a28be9ae65af08.zip tcl-427c904742d9d5aec8068fce38a28be9ae65af08.tar.gz tcl-427c904742d9d5aec8068fce38a28be9ae65af08.tar.bz2 |
* doc/expr.n:
* tests/expr.test:
* tests/expr-old.test: added tests for 'eq' and 'ne'
* generic/tclExecute.c:
* generic/tclCompile.h: added INST_STREQ and INST_STRNEQ opcodes
that do strict string comparisons.
* generic/tclCompExpr.c: added 'eq' and 'ne' string comparison
operators.
* generic/tclParseExpr.c (GetLexeme): added 'eq' and 'ne' expr
parse terms (string (in)equality check).
Diffstat (limited to 'doc/expr.n')
-rw-r--r-- | doc/expr.n | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -1,14 +1,14 @@ '\" '\" Copyright (c) 1993 The Regents of the University of California. -'\" Copyright (c) 1994-1997 Sun Microsystems, Inc. +'\" Copyright (c) 1994-2000 Sun Microsystems, Inc. '\" '\" 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.3 2000/04/28 00:47:49 ericm Exp $ +'\" RCS: @(#) $Id: expr.n,v 1.4 2000/05/09 00:00:35 hobbs Exp $ '\" .so man.macros -.TH expr n 8.0 Tcl "Tcl Built-In Commands" +.TH expr n 8.4 Tcl "Tcl Built-In Commands" .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME @@ -133,6 +133,12 @@ in which case string comparison is used. \fB==\0\0!=\fR Boolean equal and not equal. Each operator produces a zero/one result. Valid for all operand types. +.VS 8.4 +.TP 20 +\fBeq\0\0ne\fR +Boolean string equal and string not equal. Each operator produces a +zero/one result. The operand types are interpreted only as strings. +.VE 8.4 .TP 20 \fB&\fR Bit-wise AND. Valid for integer operands only. @@ -332,7 +338,10 @@ returns \fB4.0\fR, not \fB4\fR. .PP String values may be used as operands of the comparison operators, although the expression evaluator tries to do comparisons as integer -or floating-point when it can. +or floating-point when it can, +.VS 8.4 +except in the case of the \fBeq\fR and \fBne\fR operators. +.VE 8.4 If one of the operands of a comparison is a string and the other has a numeric value, the numeric operand is converted back to a string using the C \fIsprintf\fR format specifier @@ -348,11 +357,13 @@ 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 when you really want string comparison and the values of the -operands could be arbitrary; it's better in these cases to use the -\fBstring compare\fR command instead. +operands could be arbitrary; it's better in these cases to use +.VS 8.4 +the \fBeq\fR or \fBne\fR operators, or +.VE 8.4 +the \fBstring\fR command instead. .SH "PERFORMANCE CONSIDERATIONS" -.VS .PP Enclose expressions in braces for the best speed and the smallest storage requirements. @@ -383,7 +394,6 @@ The most expensive code is required for unbraced expressions that contain command substitutions. These expressions must be implemented by generating new code each time the expression is executed. -.VE .SH KEYWORDS arithmetic, boolean, compare, expression, fuzzy comparison |