httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@leland.Stanford.EDU>
Subject Re: Solaris bus error?
Date Fri, 26 Jun 1998 21:07:06 GMT
On Fri, 26 Jun 1998, Ben Laurie wrote:

> Jim Jagielski wrote:
> > 
> > All I'm saying is that it's common, recommended, taught and safe
> > practise to handle such "impossible" cases, esp when it's so simple.
> > That's not ignoring your point of, if it does fix something, then
> > we have a more serious problem.
> 
> No, no! Never handle a case that should not occur! That just hides bugs.

I agree. However, you should not assume that an impossible case will not
happen. i.e. if num should be lower than 6, saying

if (num < 5) do_something;
else if (num == 5) /* num must be 5 */ do_something_else;

do_something_that_relies_on_one_of_the_two_other_functions_being_called;

Isn't a good idea. But neither is:

if (num < 5) do_something;
else if (num >= 5) do_something_else;

I think the proper case is

if (num < 5) do_something;
else if (num == 5) do_something_else;
else quit_with_an_error;

or alternately

assert(num < 6)
if (num < 5) do_something
else /* num really must be 5 now */ do_something_else;

Or whatever...

-- Alexei Kosut <akosut@stanford.edu> <http://www.stanford.edu/~akosut/>
   Stanford University, Class of 2001 * Apache <http://www.apache.org> *



Mime
View raw message