Re: [AD] 4.3 error handling |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] 4.3 error handling
- From: Elias Pschernig <elias@xxxxxxxxxx>
- Date: Fri, 09 Jun 2006 14:48:28 +0200
On Fri, 2006-06-09 at 18:12 +1000, Peter Wang wrote:
> On 2006-06-08, Chris <chris.kcat@xxxxxxxxxx> wrote:
> > On Wednesday 07 June 2006 23:52, Peter Wang wrote:
> > > They are completely independent in my example, e.g. API1 = graphics
> > > library, API2 = network library. The _user_ is using both libraries,
> > > but neither library knows or cares about the other.
> >
> > As they shouldn't. A graphics library wouldn't call network functions, and
> > vice versa. I don't see what the problem is. The graphics library would jump
> > to its catch on error, and the network lib would jump to its catch on error
> > (just like using C++, the libs would/should throw an object of a type
> > specific to their libraries).
>
> You're right about this, sorry. I only just checked my understanding of
> C++ exceptions now (after my exam). I was thinking of `finally' in Java.
>
The problem though lies at the user, who will use both - and we can't
rely on them knowing all the gotchas when using different libs with
different setjmp/longjmp implementations. For example:
int main(void)
{
sfxlib_try {
al_try {
al_audio_init();
sfxlib_init();
}
al_catch {
printf("al_audio_init failed.\n");
}
}
sfxlib_catch {
printf("sfx_init failed.\n");
}
}
The al_try {} block must not be left (with goto, return, break, or here
with longjmp) - so this will crash.
However, in C++, it would be perfectly valud to do this, so users simpy
*will* do it, no matter how big a warning we put into the docs.
--
Elias Pschernig