On Sat, Nov 02, 2002 at 07:07:43AM -0800, Austin Hastings wrote:
> I don't recall the terminology, but I believe that "0 but true" is a
> value with a "fillintheblank" (attribute?). What happens when you stick
> "0 but true" into a bit?

    $z = 0 but true;
    my bit $x = $z;             # $x == 0
    my bit $x = ?$z;            # $x == 1
    my bit $x = true $z;        # $x == 1

I'm not even particularly upset by this:

    my bool $x = $z;            # $x == 1

But the moment anyone says

    my bool $true = 1;
    if x(1,2,3) == $true {...}

they're just asking for a world of hurt.  I am overstating the case
when I say there's no boolean type in Perl.  What I really mean is that
there is no such thing as a single true "true" value.

> > So what is the "official" way to efficiently store the result of a 
> > boolean expression, for example?  If not as a "bit", then what?
> 
> The boolean-ness is a property of the evaluation of a value: if ($a)
> ....
> 
> If the $a value has a 'but false' or 'but true' then that wins. If the
> $a value is a number, then 0 is false and everything else is true. If
> the value is a string, then ..yada yada yada..
> 
> > If anything, I would suggest a primitive type, "bool", that has no 
> > promoted type "Bool".  It can just be a placeholder -- a "bit" alias
> 
> Of course, a "bool" type would imply true/false values in the language.
> And THAT, in turn, implies that it's possible to say:
> 

I don't mind a bool type.  But you'll notice I've grabbed the keyword true()
to be a unary function.  It will not default to "true".  Perhaps it should
default to "undef".  :-)

> $.is_plugged_in = true but false;

So that probably won't even parse.

Larry

Reply via email to