home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!chsun!zurich!gegu
- From: gegu@zurich.spectrospin.ch (Gerry Gucher)
- Newsgroups: comp.lang.c
- Subject: Re: How to use 'return' in c?
- Summary: boolean != int
- Message-ID: <196@zurich.spectrospin.ch>
- Date: 9 Nov 92 20:12:24 GMT
- References: <1992Oct29.025437.9289@nuscc.nus.sg> <1992Nov2.203701.162@ipact.com> <1992Nov7.122126.24409@druid.uucp>
- Organization: Spectrospin AG, Fallanden Switzerland
- Lines: 44
-
- In article <1992Nov7.122126.24409@druid.uucp>, darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- > allebrandi@ipact.com writes:
- > >The best thing to do is to use manifest constants to implicitly document
- > >the value you are returning. For example, return TRUE or FALSE not 1 or
- > >0 for a boolean function return.
-
- >
- > Whenever I see TRUE and FALSE in code I am maintaining I remove the
- > #defines. If they are defined, they should never be anything but
- > TRUE = 1 and FALSE = 0. Anything else is confusing and misleading.
- > Given this why force the maintainer to go searching for the definitions
- > to make sure that they are what they should never be anything but?
- > This isn't as bad as #defining SEVEN as 7 but it is in the same category
- > I think.
-
-
- Sorry, I think your thinking is wrong.
-
- TRUE and FALSE are the values for a boolean type. A boolean is a
- logical concept that can yield TRUE or FALSE.
-
- An integer on the other hand is a numerical value
- that ranges (on my machine) from 2^31 -1 down to -2^31 which
- yields 2^32 values.
-
- Note quite the same, is it ?
-
- Even if these stupid machines called computer (and C compilers)
- *represent* them identically, they are still not the same thing.
-
- #define SEVEN 7 /* is of course bull..it as well as is */
- #define FORMFEED '\f'
-
- Gerry
-
-
- +------------------------------------------------------------------+
- | Gerry Gucher gegu@spectrospin.ch |
- | Spectrospin AG, Industriestr 26, 8117 Faellanden Switzerland |
- +------------------------------------------------------------------+
- | A program that returns the wrong | There is nothing wrong with |
- | result twice as fast is infinitely | making mistakes, but make |
- | slower. - H. Spencer | new ones. - D.Sim |
- +------------------------------------------------------------------+
-