On Tuesday 16 December 2003 06:08, Tom Jackson wrote:
> On Mon, 2003-12-15 at 19:59, Dossy wrote:
> >     if {[string is integer " $var"]} {
> >         ... do something ...
> >     }
>
> Interesting shortcut. I wonder why the empty string returns true for
> every class.  With the -scrict switch " 1" is also true, so strict
> doesn't really add much except returning 0 for the empty string.

shortcut maybe, but i would not recommend it as good coding practice;
In the space prefixed version a string conversion is needed also
in cases, where the type can be derived (in part) from the tcl_obj type.

Try it out, the first solution is supposed to be faster

  set x 1
  puts [time {string is integer -strict $x} 100000]
  puts [time {string is integer " $x"} 100000]

... and for reading the code, it is less magic for beginners.

-gustaf


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to