Re: [AD] 4.3 error handling

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thursday 08 June 2006 03:00, Elias Pschernig wrote:
> - just simple C code, without any #defines or hacks, looks just as clean
> as a try{} catch{} block. If you don't want gotos, you could use a
> while(1) and break statements. Still, the code flow is as clear as with
> try/catch in both cases. And, for C coders, maybe even clearer.

If you have it simple like that, yeah. Now imagine having to make more labels 
for multiple try/catch pairs in a function. Even with 2 it can easilly become 
ugly. Imagine you want two functions try'd with a common error handler. Then 
you want two more tried with another, if it was successfull. Then you want 
two more tried with a third handler regardless if the last was successful or 
not. Then regardless if that was successful or not, you revert back to a 
global error handler and continue on.

> It wouldn't make it significantly easier - but my point is, the try{}
> catch{} would mostly be liked by C++ users and not by C users, and C++
> users would be served much better with a complete C++ wrapper. Which
> then of course would throw exceptions on errors :)

Can't say I fully agree with that. I'm mostly a C coder, but I happen to like 
some features of C++. Allegro is pretty much object oriented as it is, and 
will probably be more so in the new API, meaning a C++ wrapper would do 
little more than add proper C++ exception handling (which can only go so far) 
and minor API changes. While that's all well and good, such a small change 
wouldn't attract many takers to actually make such a wrapper. Just look at 
Allegro now.. a C++ wrapper would do so much more than add proper C++ error 
handling. It could help clean up the API considerably with little added 
effort. Nobody's doing it, though, because the current method is obviously 
good enough for their needs (or they just don't have the time; either way, 
it's not done). There's been a few attempts, but they've all been dropped 
because it was too much work with too little payoff.

There's also something to be said about not having to use a wrapper at all. I 
like Allegro's API. Mainly that functions_like_this are, IMHO, infinitely 
better than zstrlpFunctionsLikeThis. If I have to use a C++ wrapper I have to 
hope whoever does it agrees with me (and they rarely do, C++ coders tend to 
prefer mixed case), and if not I'm SOL unless I make my own. It also means I 
would have to use C++ and the wrapper even if I just wanted to do a small 
fast little program in C (where C++ like exception handling without C++'s 
overhead would be really nice).




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/