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

From: Date: Wed, 19 Dec 2001 18:43:05 +0000
Subject: Re: Question: Should exit() print out the integer exit-status?
References: 1 2 3 4 5  Groups: php.dev 
Request: Send a blank email to php-dev+get-74443@lists.php.net to get a copy of this message
Lars Torben Wilson wrote:
Zeev Suraski writes:
At 15:15 19/12/2001, Lars Torben Wilson wrote:
Zeev Suraski writes:
exit_with_status(), silent_exit(), quiet_exit(), etc. etc. Something should fit :)
Yeah, you could do that. But then, why don't we have a 'c_compatible_dirname()' now, instead of a proper dirname() patch which has been proven to break BC? Because the new version is Correct--at least according to programming tradition. (Sorry, Manuel.) A function named exit(), which accepts an argument, is just _expected_ to set the exit status (assuming the coder has coded in other languages before). A better solution IMHO would be to make exit() do the right thing and create a new function named something like 'exit_print()' which behaves the way the current exit() does. Besides, as Vlad pointed out it's a _hell_ of a lot easier to do the print-out thing in userland than it is to set the exit status. :)
It's not about whether or not it's easy or not - we're not at the stage of designing the language behavior from scratch now... There's a fundamental difference between dirname(), which is supposed to answer the question of 'what directory does this file sit in?' - and there's only one correct answer. The old dirname() had a bug, period. What a function named exit() does is entirely up to us. Of course, it's expected to terminate execution by its very name, but it may do other things too, such as set the OS error code, print out an error message, etc.
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

« previous php.dev (#74443) next »