On Mon, Mar 10, 2014 at 7:33 PM, H. Peter Anvin <h...@zytor.com> wrote:
> Why not for variables?

My dislike of "bool" comes from the fact that you historically can't *trust* it.

I guess it's becoming trustworthy these days, but quite often,
traditionally, "bool" ended up being just another word for "char",
because compiler support for actual booleans was spotty, so you'd find
projects that had their own definition of bool along with true/false.

And at that point, all the advantages of "bool" fly out the window,
because they in fact act like "char" when people did that.  So
sometimes they truncated to 8 bits, and sometimes they did the "true
bool thing" and acted like truth values.

I guess I haven't gotten over my hatred of people playing games with
them because support wasn't universal enough. But maybe it's
approaching being irrational these days.

Finally: it's actually horrible mixing bool with non-bool. That
*really* screws up code generation. So if you have one function with
the traditional "int" 0/1 return style, and you use that in a function
that uses it as "bool", you'll find the compiler adding compares with
zero etc.

So I'm not a huge fan. I'm not saying bool is horribly wrong, but it
really can cause issues, and the advantages aren't really all that
obvious.

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

Reply via email to