One more point regarding = and == (more flamage)

Doug Gwyn gwyn at smoke.brl.mil
Mon Mar 25 18:17:47 AEST 1991


In article <355 at smds.UUCP> rh at smds.UUCP (Richard Harter) writes:
>But that is a different argument, one that says one should not test on any
>thing except Booleans.  If it makes you happy, fine.  Go for it; transform
>all tests into Boolean expressions.  Know, though, that in your heart you
>are not a C programmer.  C has very simple and explicit rules about 
>conditional tests.  In Fortran and Pascal you test against true and false;
>in C you test against 0 and non-zero.  Sticking an irrelevant !=0 into the
>test is no more than another of the many ways that people have of trying
>to convert C into some other language.  Saying that it is clearer is no
>more than saying "I want to read C and see Pascal".

Gee, I guess I'm not a C programmer, according to your criterion.

I have found to the contrary that introduction of an explicit Boolean
type, used completely and consistently, makes C source more
intelligible and more likely to be correct.

I would agree with an assertion that a C programmer ought to fully
understand the traditional mixed numerical and Boolean usage, but
I don't recommend coding in such a style.



More information about the Comp.lang.c mailing list