home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!kronos.arc.nasa.gov!iscnvx!netcomsv!ulogic!hartman
- From: hartman@ulogic.UUCP (Richard M. Hartman)
- Newsgroups: comp.lang.c
- Subject: Re: How to use 'return' in c?
- Message-ID: <603@ulogic.UUCP>
- Date: 14 Nov 92 01:36:56 GMT
- References: <1992Oct29.025437.9289@nuscc.nus.sg> <1992Nov2.203701.162@ipact.com> <1992Nov7.122126.24409@druid.uucp>
- Organization: negligable
- Lines: 45
-
- 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.
-
- Wait a sec.... are you saying that if I have
-
- setFlagValue(TRUE);
-
- somewhere you come along and change it to:
-
- setFlagValue(1);
-
- ??????
-
- You consider that this is easier to maintain?????
-
- It removes the intent behind the value! "TRUE" shows intent to
- use a boolean type (which does not exist in C), and that the
- function is expecting a truth value of some sort. Using "1"
- is misleading in that the next person to come along only knows
- that this function accepted some integer value without any
- clue that it was primarly a truth value.
-
- If I misunderstood your statement:
- "Whenever I see TRUE and FALSE in code I am maintaining
- I remove the #defines"
-
- I apologize for this post. But to me the statement is a bit
- unclear in it's intent. :)
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Blasting, bursting, billowing forth with |
- the power of ten billion butterfly sneezes, | -Richard Hartman
- Man, with his flaming fire, | hartman@uLogic.COM
- has conquered the wayword breezes. |
-