On Nov 29, 2007 7:40 AM, Vasiljevic Zoran <[EMAIL PROTECTED]> wrote:
>
> On Nov 29, 2007, at 8:10 AM, Stephen Deasey wrote:
>
> > It was returning a boolean value, guaranteed. It used Tcl_GetBoolean
> > to parse the value from the config file, and Tcl_GetBooleanFromObj to
> > check the default value. If both of those calls return TCL_OK, then
> > whatever comes out the other side is a valid boolean value.
>
> What about:
>
>    puts "[expr {0 == 0}]"
>
> What is this going to return in your tclsh?
> Is it going to say
>
>     true
> or
>     t
> or
>     yes
>
> ?
>
> NO. It is printing:
> 1
>
> It will NEVER print anything else. Hence you cannot
> test string equality for expressions with "false"/"no" etc
> but you CAN test it with numerical value of 0 (zero)
> or non-zero.
>
> Allright?


Not alright.

There is no dispute about what the string rep of a boolean expression
is: it's 0 or 1.

But it's irrelevant.

We're concerned with input, not output. Specifically: what does the
'if' command require as it's first argument?

The answer is: boolean. Not int. Not string.

Which is why you can test like this:


On Nov 29, 2007 7:33 AM, Vasiljevic Zoran <[EMAIL PROTECTED]> wrote:
> >
> > This is a false dilemma.
> >
> > A string equality expression is not the only substitute for an integer
> > comparison expression.
> >
> > if {$boolilicious} {   ;# <--- boolean expression
> >    puts "truthy"
> > }
> >
>
> In the IDEAL world, we would have Tcl types. But then again,
> why bother with Tcl and don't use Java or C## or something
> "typed"?


I'm not sure which ideal world you're wishing for, but here In the
real world, try this:

% set bool 1
% if {$bool} {puts "this totally worked!"}

% set bool true
% if {$bool} {puts "this sooo worked!"}


I've explained how it works, but it really doesn't matter. All that
matters is that it does, in fact work.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to