Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!bionet!ames!uhccux!munnari.oz.au!uniwa!pico!akenning From: akenning@pico.oz (Alan Kennington) Newsgroups: comp.lang.c++ Subject: Re: Time to standardize "true" and "false" Summary: Not for a very long time, probably never. Message-ID: <356@pico.oz> Date: 25 Sep 89 17:21:13 GMT References: <13730@well.UUCP> <1989Sep22.073138.19684@lth.se> Reply-To: akenning@pico.qpsx.oz (Alan Kennington) Distribution: comp Organization: QPSX Communications, Perth, West Australia. Lines: 46 In article <1989Sep22.073138.19684@lth.se> dag@Control.LTH.Se (Dag Bruck) writes: >In article <13730@well.UUCP> nagle@well.UUCP (John Nagle) writes: >> >> I would like to suggest that the time has come to standardize the >>Boolean values in C. > >I completely agree that a boolean data type is needed in C++. I >think the definition should define the following properties: [...] If a boolean type is required, it can easily be provided in C++, with whichever properties are desired. Some people like, for instance to have: enum boolean { false, true, maybe }; There must be some way of deciding which types should be built-in and which should be user-defined. Otherwise, everything would have to be put in, and then people would complain that the implementation wasn't quite what they wanted. I think it would be better to discuss the _principles_ of which types become built-in and which don't, rather than proposing particular types, e.g. "string", "complex", which should be built-ins. It seems to me that there is a very simple rule which fits C. That is that a type should be built in if a wide range of common architectures explicitly support it. Hence int, long, char, float, double, pointer-to-something, are all natural built-in types, which have machine instructions to support them. However, the single-bit boolean variable has rather few machines which support it per se. Most machines do operations on the whole byte, word, or longword, not just on one bit. These operations are indeed specifically referred to by C operations: &, |, etc. So I think that the time to add "boolean" to the built-in operators will be when common architectures support single-bit data representations and operations that are more efficient than the corresponding operations on whole bytes, words or longwords. If people want a boolean type, then the C++ classes are meant for precisely that purpose. It is contrary to the C/C++ minimalist spirit to burden the language with a non-machine-supported type. I am right, am I not? ("I'm right, aren't I?" is criticisable English.) Alan Kennington.