Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ucbvax!husc6!cca!g-rh From: g-rh@cca.CCA.COM (Richard Harter) Newsgroups: comp.lang.c Subject: Re: exit(-1) Summary: Issue is portability and good programming practice Keywords: exit, zero Message-ID: <23160@cca.CCA.COM> Date: 11 Jan 88 22:46:36 GMT References: <502@cresswell.quintus.UUCP> <6935@brl-smoke.ARPA> <1179@wjvax.UUCP> <6983@brl-smoke.ARPA> <7208@ki4pv.uucp> Reply-To: g-rh@CCA.CCA.COM.UUCP (Richard Harter) Organization: Computer Corp. of America, Cambridge, MA Lines: 30 In article <7208@ki4pv.uucp> tanner@ki4pv.uucp (Dr. T. Andrews) writes: > >Great! You've found a solution that the VMS folks could live with. >Unfortunately, those few unlucky enough to not be using VMS have been >spending their lives coding progs which finish with exit(0) when they >worked. How about a slap in the face with a wet towel to them? People who write exit(0) are violating the well known canons of good programming practice -- "Thou shalt not embed magic numbers in your code". In this case, 0 is a magic number -- it is a coded value and the wise (read those who learned by being burnt) use symbolic names which are defined in one place only. [I am guilty of this also, so if I am pointing fingers, I share the guilt.] Does it matter? That depends. If your only environment is one where the magic number is always 0 then there is no harm in using 0. If you are writing code which will be ported across operating systems then it matters a great deal. I do not understand the wet towel bit. If you are a Unix programmer in the habit of using exit(0) you are not impacted by the standard. Your code will work the way it always did. If you are writing portable code you will be grateful for a standard mechanism for handling returns that is not operating system dependent. -- In the fields of Hell where the grass grows high Are the graves of dreams allowed to die. Richard Harter, SMDS Inc.