Halt() is a non-graceful method of exiting a script.
Currently the method of exiting the script and returning a response code,
is to run the script to the very end, and place an integer at the end of
the code (the last thing evaluated in the script is treated as the response
code if it is an integer).
{{{
// start
var exitCode = 0;
if( test is ok ) {
... rest of app ...
} else exitCode = 1;
exitCode; // Exit code
// end
}}}
However other languages make use of a graceful exit function to allow the
script to be exited from any location cleanly while returning the response
code.
{{{
<?php
if( test is not ok ) {
echo "bad stuff...";
exit 1;
// A simpler common usage is die("Bad stuff...");
}
... rest of app ...
// no exit line, default is 0
}}}
Note that I am only asking for a Exit function or the like. Perhaps
something like.
Exit(code);
Exit(); // defaults to 0
I'd say please don't use 'exit', or 'die'. I'm writing a series of
libraries in JavaScript to improve the higher levels of coding.
exit;
exit=1; // it's not possible to do exit 1; so this is what I did in place.
die("string...");
Are all methods I've setup based on a Exit(code) which currently uses
Halt(); as a temporary use.
Just creating an Exit(code); would be fine enough and I could remove the
Exit I defined that uses Halt();
Original issue reported on code.google.com by nadir.se...@gmail.com on 11 Nov 2008 at 10:57
Original issue reported on code.google.com by
nadir.se...@gmail.com
on 11 Nov 2008 at 10:57