[FRIAM] div. zero bugs?
Marcus G. Daniels
mgd at santafe.edu
Tue Oct 24 02:14:53 EDT 2006
phil henshaw wrote:
> What do you guys call the class of programming errors that act like
> viruses in multiplying the complexity of a program's calculations to
> the point of overwhelming the machine, logical flaws that have the
> effect of dividing by zero.
One class of exceptions I'd call "passing the buck". "I don't know
what to do so I'll go through some obligatory motions and give this to
the caller" (Inserting some junk code to show they thought about the
possibility for a few seconds.) Sooner or later a user of the library
code and punts and ignores the whole thing and then some potentially
weird failure occurs a bit later. In C, for example, this idiom:
if ((ptr = malloc (100)) == NULL) return -1;
[A memory allocation failure is pretty much always fatal anyway -- they
might as well just abort so the failure is localized when someone looks
at it in a debugger. Instead of it sneaking away by a few layers of
indirection.]
In Common Lisp, and to some extent in Java, there is an orthogonal
technique for dealing with exceptions. Any code that can fail can
signal a hierarchy of exception types, and then user can (or must) trap
them with separate code. Common Lisp fully separates signaling,
handling, and recovery in a nice object-oriented way:
http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html
More information about the Friam
mailing list