Re: Question: Should exit() print out the integer exit-status?

From: Date: Wed, 19 Dec 2001 22:27:12 +0000
Subject: Re: Question: Should exit() print out the integer exit-status?
References: 1 2 3 4 5 6  Groups: php.dev 
Request: Send a blank email to php-dev+get-74461@lists.php.net to get a copy of this message
Vlad Krupin writes: > Lars Torben Wilson wrote: > >Perhaps I have not explained my position. I don't care whether it > >outputs the exit status as a string--as long as it sets the error code > >appropriately *as well*. By appropriately, I mean that 'exit("boo");' > >would a) print 'boo' and b) return with exit status 0, but > >'exit("1boo")'; would a) print '1boo' and b) return with exit > >status > >1. This would be consistent with PHP's type conversion rules, and > >would also tend to behave in the way that the programmer expects it > >to. > > > Yikes. This is way worse than overloading. In school they called that > data-coupling, I think. In real life this is called a hack. > > Sorry, but a -1 on this. > > Vlad No, it's called loose typing. See http://www.php.net/manual/en/language.types.string.php#language.types.string.conversion We have a language here which considers the integer value of "5" to be 5, and an exit() construct which ignores that. For instance: shanna% php -q <?php exit('5'); ?> 5 shanna% echo $? 0 shanna% php -q <?php exit(5); ?> 5 shanna% echo $? 5 How much sense does this make? None, as far as I can see. What I'm proposing is to make the behaviour of exit() _not_ depend on the type of its argument. At present if the argument is an integer exit() prints it and sets the error status, but if it's any other type, exit() just prints it and doesn't set the exit status. This is more complex than my proposal: no matter what the argument is, print out its string value, and set the exit status to its integer value. AFAICT exit() is currently broken wrt how it handles the type of its argument. -- Torben Wilson <torben@php.net> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506

« previous php.dev (#74461) next »