Ralph Giles wrote:
implementing an exception handler. Without 'goto' cleanup code has to be
duplicated for every fatal error check, and using macros instead is even
harder to keep track of when reading the code. As long as the jump
I don't think this is true. I haven't found a use of goto that can't be
converted into a simple wrapper function with return statements, e.g.,
do_something_impl(...){
//Do something...
if(failure)return error;
//Do something else...
if(failure)return error;
//...
return success;
}
do_something(...){
//Allocate resources
//...
ret=do_something_impl(...);
//Free resources
//...
return ret;
}
You can argue about whether or not that's any cleaner than using goto,
and I wouldn't insist that you don't, but at least this makes it clear
that you can't get out of do_something() without cleaning up your
resources (in this particular example), yet doesn't require code
duplication or macros.
_______________________________________________
dev-media mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-media