home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!utcsri!torn!utzoo!telly!druid!darcy
- From: darcy@druid.uucp (D'Arcy J.M. Cain)
- Subject: Re: How to use 'return' in c?
- Message-ID: <1992Nov17.033541.10382@druid.uucp>
- Date: Tue, 17 Nov 1992 03:35:41 GMT
- References: <1992Nov2.203701.162@ipact.com> <1992Nov7.122126.24409@druid.uucp> <603@ulogic.UUCP>
- Organization: D'Arcy Cain Consulting
- Lines: 53
-
- hartman@ulogic.UUCP (Richard M. Hartman) writes:
- >In article <1992Nov7.122126.24409@druid.uucp> darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- >>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.
- >Wait a sec.... are you saying that if I have
- > setFlagValue(TRUE);
- >somewhere you come along and change it to:
- > setFlagValue(1);
-
- After I make sure that TRUE is defined as 1. If it isn't I change the
- name to something else. I really don't feel like looking it up more
- than once. I certainly don't have any problem with a function name
- like "setFlagValue()." It's pretty obvious that a function with a
- name like that is looking for a true or false value.
-
-
- >You consider that this is easier to maintain?????
-
- Yes. Why so shocked?
-
- >It removes the intent behind the value! "TRUE" shows intent to
- >use a boolean type (which does not exist in C), and that the
- ^^^^^^^^^^^^^^^^^^^^^^^^^
- Exactly.
-
- >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 it matters they probably have to know more about the function
- than that it takes some sort of integral value.
-
- >If I misunderstood your statement:
- > "Whenever I see TRUE and FALSE in code I am maintaining
- > I remove the #defines"
-
- Well that may be a bit strong I suppose. I mean I don't make wholesale
- changes to code that I am making one or two trivial changes to but if
- it is something that I am doing a major rewrite to then yes that would
- be one of the early candidates for cleanup.
-
- >I apologize for this post. But to me the statement is a bit
- >unclear in it's intent. :)
-
- But it is a TRUE statement. :-)
-
- --
- D'Arcy J.M. Cain (darcy@druid.com) |
- D'Arcy Cain Consulting | There's no government
- Toronto, Ontario, Canada | like no government!
- +1 416 424 2871 DoD#0082 |
-