home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!sun-barr!cs.utexas.edu!rutgers!modus!systemy!oliver!ugo
- From: ugo@oliver.sublink.org (Ugo Cei)
- Newsgroups: comp.lang.c
- Subject: Re: The Correct Way To Write C if-Statements
- Message-ID: <1992Nov21.133259.29914@oliver.sublink.org>
- Date: 21 Nov 92 13:32:59 GMT
- References: <1992Nov12.101654.21932@thunder.mcrcim.mcgill.edu> <1992Nov12.140710@gese.ge14.mdadv.gv.at> <3860@dozo.and.nl> <1992Nov16.175117.29633@dg-rtp.dg.com> <BxvIyA.Co2@sci.kun.nl>
- Organization: Oliver System - Pavia ITALY
- Lines: 18
-
- I am surprised that nobody has yet suggested this style:
-
- (cond) && expression;
-
- or (cond) && (expression, 1); in case "expression" has void type.
-
- e.g.: (1 == 1) && puts("1 == 1");
- instead of if (1 == 1) puts("1 == 1");
-
- If you want to reverse the condition, change "&&" to "||".
-
- Ugo
-
- P.S.: should I put a smiley in ? BTW, this is a common Perl idiom.
-
- --
- Ugo Cei --- Via Colombo 7 - 27100 Pavia - ITALY |
- -- Sublink: ugo@oliver.sublink.org | "Real programs dump core"
-