Exception Hierarchies

Stewart MacLean stewart.maclean at nzhis.govt.nz
Wed Aug 18 03:08:20 UTC 1999


 
> From:  Dean Swan at MITEL on 08/17/99 12:00 PM
> 
> With all the discussion of exceptions, I feel compelled to 
> add to the din.

[snip - interesting stuff about low level exceptions]

> > This whole concept of users being able to define EXCEPTIONS 
> themselves (which
> seems to have really been popularized by C++ - what a horrid 
> language)  just
> seems to be a disaster waiting to happen. ...

Hi Dean,

I take exception (sorry ...) to this! (not the bit about C++, strongly
agree!)

User definable exceptions provide a high level control flow construct
(rather akin to gotos!) which are very useful for implementing backtracking
problems in Smalltalk. See for example a rather old program design
technique, Jackson Structured Programming. For selections where you don't
know which branch to take, or iterations where you don't know whether to
continue or not.

For example where you're half way through processing a batch before you know
its a dud:

	["Batch posit 
		GoodBatch seq" 
			...

		ExceptionOneCondition ifTrue: [ExceptionOne raise].
			...
		ExceptionTwoCondition ifTrue: [ExceptionTwo raise].
			...
		"GoodBatch end"]
		on: ExceptionOne, ExceptionTwo
		do:  
	["Batch admit  
		BadBatch seq"
			...
		"BadBatch end"
	Batch end"].

Cheers,

Stewart

	





More information about the Squeak-dev mailing list