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: <1992Nov12.125524.20896@druid.uucp>
- Date: Thu, 12 Nov 1992 12:55:24 GMT
- References: <1992Nov7.122126.24409@druid.uucp> <gm5XTB3w165w@quest.UUCP>
- Organization: D'Arcy Cain Consulting
- Lines: 25
-
- srhqla!quest!kdq writes:
- >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.
- > On the other hand, since C does not truly support the boolean type,
- >I consider it misleading to assign a numeric value to a boolean. I
- >define TRUE as (1==1) because the result of this is a boolean - the
- >fact that it is represented by a numerical value is misleading.
-
- Well as you say, C does not support the boolean type. A true expression
- evaluates to 1 and a false to 0. That's the definition of the language.
- (1==1) evaluates to 1 so it is the same as defining TRUE as 1. If I see
- TRUE and FALSE in your code i *still* have to check that it is defined
- correctly. The fact that your definition works is irrelevant, it still
- costs me time to confirm that.
-
- To me it seems like defining SEVEN as 7. It's correct but I wouldn't
- do it.
-
- --
- 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 |
-