2007/5/1, erik quanstrom <[EMAIL PROTECTED]>:
>
> I've seen more than my fair share of tf = !!value; out there, which is
> just awful to read. It is very useful to have a defined way of
> determining the binary success or failure of an operation without
> having to understand whether -1, 1, 0, 38, or -129125 is success,
> failure, or indication of an error condition.

i'm not sure why a boolean type fixes this problem.  using _Bool
in this case shoves some implicit magic into '=' that wasn't there
before and doesn't map at all to how the machine really works.

what's wrong with this?

        if(tf != 0)
                return 0;
        return -1;

Nothing is wrong with that, but the point is that it isn't always that
simple. UNIX in general has different meanings in different places.
This isn't C's fault, but not having a boolean type has contributed to
this (ab)use of the meaning of magic integers. Sometimes non-zero is
true and zero is false. Sometimes 0 is true and non-zero is false.
Sometimes 0 is true and non-zero indicate differing levels of
falseness.

It doesn't fix these problems but it discourages them from happening
in the future.

Anyway, indeed, this is a C language discussion, so to not be
completely off topic, what I typically do in Plan 9 is:

enum {
   true,
   false,
};

(Yes, I know this still has nothing to do with Plan 9, but I tried :))

- erik

I'll digress from this thread, because I'm certainly not the best
person to determine what parts of C are good nor bad. Just to bitch
about my own use. I think boolean types are a good thing. But I won't
pollute this list further (and sorry for the current level of
pollution) :(

--dho

Reply via email to