On Tue, Mar 15, 2005 at 12:28:15PM -0700, Marcus Adair wrote:
: Isn't saying "false doesn't exist" like saying, "dark doesn't exist"? 
: Why have a word for that?
: 
: I'm really afraid I'm missing something obvious here, but I'm worried 
: that neither "whether" nor "indeed" work very well in many contexts. It 
: seems to me that testing trueness exists in so many contexts that it's 
: going to be hard to find an English word that fits all the important 
: ones.

Most of those contexts are implicitly boolean, and this function would
be redundant there.  The main use for this function is to provide a
boolean context for its argument and return 0 or 1 when you really
do want 0 or 1 for some context that isn't directly boolean.  This
is actually relatively rare.

: Additionally I question whether this is truly a case improving to the 
: point of least surprise? After all, I don't know a programmer who's 
: going to be surprised by what true means. There are still *some* things 
: you may have to learn in software dev 101 ;)

The point is that most people coming from other languages would expect
"true" to be a true value, not a function testing whether some other
value is true.  It would be particularly confusing if we made it
default to testing $_, in which case

    $_ = 0;
    if 1 == true { say "true" } else { say "false" }

would say "false".  It is a little less confusing in

    given $value {
    when true {...}

except that, in fact, both of those cases would be syntax errors if
true were a function, since it would parse the following block as an
argument to true.

So if we really want to test a value for whether its .bit property
returns the bool::true value, we will probably require you to use
the method syntax:

    when .true {...}

and then it's obvious that there's some object involved.  (And it parses
right, because .true would require parens if there were arguments.)  On
the other hand, these also do the same thing underneath, at least in
the abstract:

    when ?$_ {...}
    if $_ {...}

The optimizer is likely to bypass actually calling the .bit/.true method on
known types, however.

Larry

Reply via email to