comp.lang.tcl
[Top] [All Lists]

Re: expr and strings

Subject: Re: expr and strings
From: "Gerald W. Lester"
Date: Sat, 31 May 2008 11:33:17 -0500
Newsgroups: comp.lang.tcl


Kevin Kenny wrote:
Gerald W. Lester wrote:
On the other hand, as we have eq and ne to compare strings, shouldn't
we have a lt, le, gt, ge for explicit string comparison and leaving <,
<=, >, >= specifically for integer comparison?

No, because that would break an *awful* lot of existing scripts.

Actually, as long as [string compare] remains, 'lt', 'le', 'gt', 'ge'
can be implemented without any script breakage at all.

Adding  'lt', 'le', 'gt', 'ge' could be done without breakage.

The breakage part comes from "leaving <, <=, >, >= specifically for integer comparison" (I assume he really meant numeric comparisons since a lot of us do like to deal with real numbers). The following would no longer work:

% expr {a < b}
syntax error in expression "a < b": variable references require preceding $
% set a a
a
% set b b
b
% expr {$a < $b}
1


And I've been
contemplating proposing exactly that.  But I've been holding off
because dgp appears to be planning major surgery on the expression
parser, and the change will be easier to work in once he's done.


--
+--------------------------------+---------------------------------------+
| Gerald W. Lester                                                       |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy