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), 0 is sometimes magic Summary: What is a magic number? Keywords: exit, zero, flaming Message-ID: <23329@cca.CCA.COM> Date: 17 Jan 88 05:54:39 GMT References: <502@cresswell.quintus.UUCP> <6935@brl-smoke.ARPA> <1179@wjvax.UUCP> <6983@brl-smoke.ARPA> <7208@ki4pv.uucp> <23160@cca.CCA.COM> <1843@bsu-cs.UUCP> <2305@bloom-beacon.MIT.EDU> <1868@bsu-cs.UUCP> Reply-To: g-rh@CCA.CCA.COM.UUCP (Richard Harter) Organization: Computer Corp. of America, Cambridge, MA Lines: 92 In article <1868@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: >I gave a number of example attempting to show that zero is inherently >a unique integer and therefore not a "magic number" in the usual >sense of the term. > ... Discussion of the properties of zero deleted ... > >It seems to make perfect sense to me that in the non-VMS world in which >a single successful termination value, and multiple failure termination >values, are needed, zero should be the successful termination value. > >Therefore the use of exit(0) for successful termination is not >arbitrary. It is intuitively correct. This is perhaps my fault for assuming that everyone knows what is meant by a magic number, as in "don't use magic numbers". Let me give an example. Look at the following code: char foo[57]; .... for(i=0;i<57;i++) {...} foo[55]='\n'; foo[56]='\0'; As we all know, this kind of code is likely to create maintenance problems. If, for some reason, we want to change the size of foo, we must identify and change every occurence of 57, including the indirect ones. Experienced programmers will prefer something like this #define size 57 .... char foo[size]; .... for (i=0;i