Re: RFC: booleans and the kernel

From: Jamie Lokier (lk@tantalophile.demon.co.uk)
Date: Sat Jan 26 2002 - 11:27:47 EST


Gábor Lénárt wrote:
> Khmmm please enlighten me ...
>
> > if (X == true && ptr && *ptr > 1)
>
> Why? Simply use for example type 'char' as boolean value. Let's say
> 0 means false and other value is true.
>
> So:
>
> if (x) printf("true");
> or
> if (!x) printf("false");
>
> Why do you want to overcomplicate?

If the variable holds a boolean in the C language, fair enough but if
it's being used as a range in a truth-value system of _another_
language, i.e. it simply _represents_ a truth value, I would write it
differently.

If it were a theorem proving paper, the different kinds of variable
would have a different font or colour :-)

> x=a>b;
> if (x) printf("A is greater than B");
>
> ONE thing which is best in C is the less strictly type rules eg you
> can use 'char' to store eg c='A' or c=2.

You seem to have missed the point. We _know_ the C language rules. I
agree that non-strict typeing is quite useful, although C is in fact
quite strict. Lisp has far less strict typing :-)

> Hey guys, C was designed to write an OS it's not something other ...

Perhaps, but it's pretty useful for something other.

-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jan 31 2002 - 21:00:40 EST