From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucio De Re To: 9fans@cse.psu.edu Subject: Re: [9fans] same functions everywhere Message-ID: <20030507124006.D26796@cackle.proxima.alt.za> References: <20030501160047.7231.qmail@g.bio.cse.psu.edu> <000c01c3147c$c7665ae0$7b83773e@SOMA> <3EB8E817.4090609@ameritech.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: <3EB8E817.4090609@ameritech.net>; from northern snowfall on Wed, May 07, 2003 at 06:03:51AM -0500 Date: Wed, 7 May 2003 12:40:09 +0200 Topicbox-Message-UUID: a150df46-eacb-11e9-9e20-41e7f4b1d025 On Wed, May 07, 2003 at 06:03:51AM -0500, northern snowfall wrote: > Exceptions in a C environment is basically admitting that you > don't understand enough about C to promote elegant and simple > solutions to complex problems in that language. Putting the > blame on C, itself, is simplistic and, frankly, arrogant. I don't go along with that. Consider the conventional linear search of an array: int a[100]; int x, v; ... x = 0; while (x < 100 && a[x] != v) { ++x; } (or whatever version you prefer). At the end, you always have to determine whether you found the desired element or exceeded the array bounds. Now, if exceeding the array bounds could be treated as an exception (imagine a clever CPU with array bounds checking in hardware delivering a segment violation error), you could write: x = 0; while (a[x] != v) { ++x; } and at the end you'd know that the element was found, because the exception wasn't triggered. Better, you'd not even reach the end of the loop if the element wasn't found. This particular problem has bugged me for decades :-) I go along with Doug that exception handling can hide the extremely uninteresting code involved in dealing with rare or "off band" conditions. ++L