From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] same functions everywhere From: rog@vitanuova.com In-Reply-To: <3EB87BDC.30305@null.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Wed, 7 May 2003 16:06:33 +0100 Topicbox-Message-UUID: a24af558-eacb-11e9-9e20-41e7f4b1d025 > > what kinds of exceptional conditions are you thinking about here? > > What would be considered "problems in completing the assignment". > Typically, running out of some system resource, or a already > created data structure is found to have an "impossible" value in > some field, etc. i think that sounds completely reasonable, and, despite rob's comments, is de facto the case in many places in plan 9 (if you try to use a nil data structure, divide by zero, etc). IMHO there's probably a good case for extending this kind of exception raising to other errors where most programs will be unable to recover, the classic example being out-of-memory errors. > The idea is that things that are expected to > occur quite a lot should be dealt with in the main logic, since > not taking them into account would be an essential lack of > function, but that things that should rarely occur and are not > of the same kind as expected results should be treated as > exceptions. with this, however, i have to disagree. i believe an exception should represent a genuinely exceptional condition, i.e. something which one would not normally expect to happen during the usual execution of the program. if something occurs rarely, it's not necessarily exceptional in any way. > One could debate whether getc() returning EOF with ferror() returning > false should be handled as an exception rather than as an exceptional > value for the data, but I'm inclined to think that it should, after > consideration of the problems that having in-band signals has caused. this is a good example. encountering the end of a file is in no way an exceptional condition. in fact, for most programs, this condition occurring is a pre-requisite for correct operation of the program! using exceptions for this kind of thing makes the code harder to read, which is a cardinal sin. in a normal program, i should never have to deal with exceptions at all. (BTW, getc doesn't use in-band signalling, and even if it did, tuples are a much cleaner solution than exceptions, IMHO).