On Tue, Feb 17, 2004 at 01:54:53PM -0600, Kenneth Pronovici wrote:
> On Tue, Feb 17, 2004 at 07:21:00PM +0000, Will Newton wrote:
> > On Tuesday 17 Feb 2004 4:58 pm, Andrew Suffield wrote:
> >
> > > > void shoe()
> > > > {
> > > > /* Do some complicated stuff */
> > > > if (foo == NULL)
> > > > goto cleanup;
> > > > /* Continue complicated stuff */
> > > > if (bar == 3)
> > > > goto cleanup;
> > > >
> > > > cleanup:
> > > > /* Cleanup */
> > > > }
> > >
> > > Good grief, that's *terrible* C. Don't do things like that. The
> > > problem here is not a lack of exceptions, it's just bad code. As
> > > usual.
> >
> > As usual? OK.
> >
> > That is an often used convention, used by many substantial pieces of C code
> > that you are running on your system right now. Admittedly it is much more
> > often used in system level situations than application code.
>
> In fact, K&R even recommends this approach when cleanup is required, so
> it's not as if there isn't precedent:
>
> This organization is handy if the error-handling code is non-trivial,
> and if errors can occur in several places. [1]
K&R is a veritable tome of bad advice. It really should be avoided;
it's horribly outdated. Optimising compilers have obsoleted most of
it (at the time when it was written, function calls weren't cheap).
--
.''`. ** Debian GNU/Linux ** | Andrew Suffield
: :' : http://www.debian.org/ |
`. `' |
`- -><- |
Attachment:
signature.asc
Description: Digital signature