Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: Definition of boolean type Message-ID: <2113@buengc.BU.EDU> Date: 13 Feb 89 00:32:13 GMT References: <10@dbase.UUCP> <9609@smoke.BRL.MIL> <3645@arcturus> <15906@mimsy.UUCP> <27989@ucbvax.BERKELEY.EDU> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 21 In article <27989@ucbvax.BERKELEY.EDU> jas@ernie.Berkeley.EDU.UUCP (Jim Shankland) writes: > >I agree with Karl Heuer: C would have benefited from a built-in boolean >type. As is, conscientious programmers will avoid type punning between >values that are conceptually boolean with those that are conceptually >integers (though as far as C is concerned, of course they're both integers.) Low-sophistication point-of-interest, approx. 20 mills in value: You can be conscientious if, when unsure of the return value, and you _like_ having true==1 and false==0, then say boolfoo = !!expr_returning_funny_bools; which, according to my KnR, should never ever give any boolfoo other than 0 or 1, even if the expr has a dozen different values for true. (See the description of the '!' op. I think it's around page 187 of ed. 1.) --Blair "!!(But I can't be sure...)"