--- Michael Lazzaro <[EMAIL PROTECTED]> wrote:
> 
> On Friday, November 1, 2002, at 08:02  AM, Mark J. Reed wrote:
> >> When someone asks "what's the boolean type in Perl?" I'd rather 
> >> answer "bit" than "Perl doesn't have one", if for no other reason 
> >> than the latter answer will completely freak them out.  :-)
> > Why?  Plenty of languages get along just fine without a Boolean
> type.
> > BASIC, C, LISP, Perl5, Python, TCL . . .
> 
> In langs that do not recognize boolean as a type, the convention is 
> either to use an untyped thing or the "littlest possible" thing as a 
> boolean type.  (The latter has more possibilities for efficiency, 
> obviously.)  Let's look at a presumably common Perl6 construct:

Umm, this just ain't so. 'C' uses the int type as its basic boolean.
You may be inclined to store the values in a char or a bitfield, but
(a==b) is an int.

> Since a "bit" can't even have properties (tho a "Bit" can), it really
> is, for all practical purposes, a boolean value, and can be treated
> as such.  Fine and dandy, that's OK.

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?

> 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:

$.is_plugged_in = true but false;

Maybe this should be an option only for female programmers? (Hoping my
GF isn't reading this... :-)

Frankly, I don't have a problem using a numeric value as a boolean. I'm
used to it. If there were a boolean primitive type, I probably wouldn't
use it correctly sometimes -- too much C/assembly work. But what's
wrong with defining Boolean as a subtype of bit?

On a vaguely-related note:

It's possible to say 

$result = $value but true;

Is it possible to use a variable in that expression?

$result = $value but $bool;

If so, does it dwim? How do I use it?

$bool = "true"; ?
$bool = true; ?
$bool = (1 == 1); ?

=Austin






__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

Reply via email to