| Store | Cart

Re: [TCLCORE] TIP #461: Separate Numeric and String Comparison Operators

From: Peter S <pete...@gmail.com>
Wed, 1 Feb 2017 17:41:35 +0100
If one argument a number, and the other is a list, that still results
in numeric comparison:

    % expr {0x1 == [list 1]}    --> 1
    % expr {0x1 == {1}}   --> 1

One argument can be quoted, doesn't change this:

    % expr {"0x1" == [list 1]}    --> 1
    % expr {"0x1" == {1}}    --> 1

This is because, lists are also just strings (EIAS):

    % expr {1 eq [list 1]}    --> 1
    % expr {1 eq {1}}    --> 1
    % expr {1 eq "1"}    --> 1

If one argument has whitespace, that's still a numeric comparison:

    % expr {0x1 == "  1  "}    --> 1
    % expr {0x1 == "\t1\n"}    --> 1

Currently all the documentation on the behaviour of == in the manual:

    "Valid for all operand types."

That's *all* the [expr] manual says about ==.

Regards,
Peter

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

Recent Messages in this Thread
Donald Porter Jan 31, 2017 05:09 pm
Peter S Jan 31, 2017 09:45 pm
Brad Lanam Feb 01, 2017 12:04 am
Kevin Kenny Feb 01, 2017 01:09 am
Brad Lanam Feb 01, 2017 01:26 am
Dipl. Ing. Sergey G. Brester Feb 01, 2017 07:57 am
Peter S Feb 01, 2017 01:13 pm
Peter S Feb 01, 2017 01:23 pm
Colin McCormack Feb 01, 2017 02:33 pm
Peter da Silva Feb 01, 2017 04:16 pm
Peter S Feb 01, 2017 04:27 pm
Peter S Feb 01, 2017 04:41 pm
Peter S Feb 01, 2017 05:10 pm
Peter S Feb 01, 2017 05:48 pm
Dipl. Ing. Sergey G. Brester Feb 01, 2017 06:45 pm
Peter S Feb 01, 2017 06:48 pm
Peter S Feb 01, 2017 10:07 pm
Peter S Feb 01, 2017 10:30 pm
Brian Griffin Feb 01, 2017 10:48 pm
Dipl. Ing. Sergey G. Brester Feb 01, 2017 05:11 pm
Peter S Feb 01, 2017 04:13 pm
Martin Lemburg Feb 01, 2017 03:31 pm
Martin Lemburg Feb 01, 2017 12:20 pm
Dipl. Ing. Sergey G. Brester Feb 01, 2017 01:20 pm
avl Feb 01, 2017 12:01 am
Donald G Porter Feb 02, 2017 06:21 pm
Peter S Feb 01, 2017 10:59 pm
Dipl. Ing. Sergey G. Brester Feb 02, 2017 08:29 am
avl Jan 31, 2017 05:04 pm
Peter S Jan 31, 2017 05:13 pm
Messages in this thread