Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!uc!nic.MR.NET!vixvax.mgi.com!spanky.mgi.com!cepek From: cepek@spanky.mgi.com Newsgroups: comp.lang.c Subject: Re: boolean Message-ID: <24.266bdce0@spanky.mgi.com> Date: 5 Jun 90 21:25:04 GMT References: <12986@smoke.BRL.MIL> <5907@buengc.BU.EDU> <4232@castle.ed.ac.uk> <13003@smoke.BRL.MIL> <20.266429f6@spanky.mgi.com> <16784@haddock.ima.isc.com> Followup-To: comp.lang.c Organization: Management Graphics, Inc. Lines: 52 In article <16784@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes: > In article <20.266429f6@spanky.mgi.com> Cepek@MGI.COM writes: >> Among our "company-common" .H files, the compiler/target-machine dependent >> one includes the following pseudo-types: >> #define bool int8 /* smallest entity for TRUE or FALSE */ >> #define boolean int /* fast/simple entity for TRUE or FALSE */ >> >> This allows the programmer to choose between space and speed. > > Defining both `bool' and `boolean', with different meanings, is probably a > mistake. The very existence of a typedef named `int8' is questionable. (Yes, > I know the reason.) I will (have) start(ed) a separate thread for this topic. > And it's probably not worthwhile to have the `small' > type, since if you have enough of them that the factor of (probably) 4 is > significant, you might as well also go for the factor of (probably) 8 that you > get by using packed bit vectors. (The time cost isn't as bad as one often > hears, since you don't normally have to go around packing and unpacking the > things--the common operations on booleans are test, set, and clear, none of > which is hard. The only real pain is that you can't use normal C syntax; you > have to go through macros.) OK, so to summarize the ups and downs of both ways of implementing "bool": _int_8_bool_ _bitfield_bool_ normal C syntax versus using "painful" macros quicker versus "not too bad" time cost less dense versus more dense (twice) The most significant item for me, a programmer using this, is item #1. The last thing I want to have to cope with is an awkward syntax for doing something simple. Also, switching from using a "bool" to using a "boolean" (or vice versa), is very easy (if rare). Item 2 is nice, but not significant (for us). Item 3 is also not very important in our situation; we appreciate the extra density beyond "boolean", but maximal density isn't important. - - - - - - - - - - - - - - - - - - - - I'm not trying to start a war here. I've only been using C for 4 years (programming for 12). I'm all for learning new methods and discussing alternative approaches; in fact I enjoy it. +------------------------------------------------------------------------+ | Michael Cepek "Engage." | | Programmer/Analyst | | Internet: Cepek@MGI.COM | | Management Graphics, Inc. Voice: +1 612/851-6112 | | 1401 East 79th Street Operator: +1 612/854-1220 | | Minneapolis, MN 55425 USA Fax: +1 612/854-6913 | +------------------------------------------------------------------------+