Re: unused for all platforms



On Mon, Feb 18, 2002 at 07:51:35PM +0100, Daniel Egger wrote:
> > BTW.
> > What about implementing exception handling in terms of setjmp/longjmp like DCE
> > does?
> 
> I'm probably not the right person to comment this question as I don't
> know much about either setjmp/longjmp or DCE. Maybe you can explain what
> this would mean and where the benefits are?

setjmp() saves the actual execution context in the given buffer
longjmp() restores the execution context from the given buffer (it must be
	created by previous setjmp() call)

This way you can jump out off many stack frames (function calls). It behaves
like exception throwing.

The concept
void f (void)
{
	if (bed1)
		THROW (exception1);
	if (bed2)
		THROW (exception2);
}

TRY {
	f ();
}
CATCH (exception1) {
	some cleanup action
}
CATCH (exception2) {
	some cleanup action
	RETHROW;
}
CATCH_ALL {
	some cleanup action
	THROW (exception3)
}
ENDTRY

TRY, CATCH(), ... are macros hiding the actual exception engine

after RAISE in f() the actual thread continues in the catch block for given
exception they perform some actions (mostly cleanup) and
rethrow / throw other exception or continue after ENDTRY.

the benefits:
some standards as w3 dom specification define exceptions and method raising
them as part of the specification.
In C it can be implemented either
- using a compiler/os support (Windows)
	os / compiler dependent
- passing an extra parameter which holds the actual exeption
	checking for exception after each call to such method
- using concept like this
	generic functionality

Regards
-- 
Miroslaw Dobrzanski-Neumann

MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne mosaic-ag com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]