[GRASS5] some thoughts

Glynn Clements glynn.clements at virgin.net
Fri Jan 18 03:26:29 EST 2002


Roger Bivand wrote:

> > Ultimately you can only get so much integration before separate
> > processes start to become a problem. But eliminating the exit() calls,
> > opportunities for fatal errors[1] and memory leaks isn't going to
> > happen overnight.
> > 
> > [1] By which I basically mean crashes. G_fatal_error() can be modified
> > to allow a "fatal" error handler to be installed which could call
> > setjmp() rather than exit(). This would allow "exception" style error
> > handling rather than having to pass NULL/-1/whatever all the way up
> > the call stack.

Of course, I meant longjmp().

> > 
> The R interface "takes over" error handling from libgis.a as:
> 
> void R_G_init(char *name) {
> 
> 	G_set_error_routine(R_handler);
> 	G_sleep_on_error(0);
> 	G_gisinit(name);
> }
> 
> with R_handler() being a simple function that passes the error on within
> R.

Right; you've already done that bit.

I was thinking about supporting pushing/popping error handlers, along
with try/catch/throw macros. Given that most code just gives up and
quits as soon as something goes wrong, status returns mostly just make
the code ugly.

> If modules never use exit() but only G_fatal_error(), this works
> smoothly in my experience.

Unfortunately, a fair amount of code currently just calls exit(). But
that isn't hard to change, just a lot of donkey work.

-- 
Glynn Clements <glynn.clements at virgin.net>



More information about the grass-dev mailing list