Re: Exceptions in glib



Owen Taylor <otaylor redhat com> writes:

> The suggestion to add setjmp/longjmp exceptions has come up a lot.
> The answer we've always arrived at is no.
> 
>  - It's not portable.

That's not true. We're using a setjmp/longjmp-based exception
mechanism in the Gwydion Dylan compiler, and it has been ported to
just about any platform one can think of, without any problems.

>  - It's not safe if you have code in between that isn't expecting it

That's true. The big question for me is whether it is more work to
make all the software consistently deal with exceptions, or make all
the software consistently pass around an additional error parameter. I
suspect the latter to be more work.

Also, this problem could be remedied by using callback-based
exceptions.

>  - It's not safe with any language beside C.

You'd need to catch exceptions at the interface between C and whatever
language you're using, and translate the exception into the native
representation (which for some languages could again be exceptions).

> Etc. The error handling mechanism we've introduced for GLib-2.0
> is just a simple extra-parameter:

Will that be used consistently everywhere? The problem we've been
discussing was a non-fatal out-of-memory situation. Sure I can call
g_try_malloc, but what if I call some library function? How should it
know which malloc to call?

Thanks for answering my questions, and I hope I'm not beating a dead
horse here.

Andreas




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