Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Most obscure bug *ever*

Author: Dave Gomboc

Date: 04:37:51 10/25/02

Go up one level in this thread


On October 25, 2002 at 05:05:59, Dann Corbit wrote:

>Writing stuff that anticipates errors and corrects them is a lot harder than
>writing something that simply rejects them and quits.

>The EPD kit from crafty drives me nuts sometimes.
>
>It simply stops running when it encounters a problem.  That's the worst possible
>behavior I can imagine, except crashing the machine.
>
>If something obvious is done wrong (e.g. "QK -" instead of "KQ -" it croaks.  It
>would clearly be harder to write something that tries to make sense out of
>questionable input.
>
>The problem is that a huge percentage if input is questionable.  I prefer
>something that fixes and goes on (or reports the problem and goes on, or at
>worst ignores and goes on) to something that just stops running.
>
>And I do think that Tim Man's solution of allowing 0-0-0 and 0-0 for castling is
>better than refusing to parse the game.  The same is true for all his other
>fixes to crappy input.

It doesn't have to quit!  Just because I throw an exception doesn't mean that I
don't catch it. ;-)  It would be reasonable to emit an error message, skip over
the game, and continue processing the next one.  In the absence of a good user
interface for correcting input errors on-the-fly, the software could output two
files, one for "good games" and one for "bad games" -- the latter with
appropriate diagnostics, so that you can fix the bad ones conveniently, cat the
two files together again, and have no more grief.

In an environment where there is a lot of crappy input, and some of it can be
predictably fixed by an algorithm, then certainly it is reasonable for code to
(try to) do that.  But my point is that the code that does this should _not_ be
the same code that handles correct input!  If I want to patch up a broken EPD
string, the right place to do this isn't where you read it in and segment it.
Error recovery belongs in a different block of code -- this is why modern
languages have exception support.  The patched-up string can be sent back to the
original routine if the program wants to give it another try afterward.

I agree with most of your preferences, but not the last: I'd prefer stopping
with an error message to "ignoring and going on" every day of the week.  IMO
"ignoring and continuing" is the worst possible choice.

Dave



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.