On Mon, Feb 11, 2008, Amos Jeffries wrote:

> > I end up with -one- exit location in the function and I don't have to
> > bum around using extra functions or massively nested conditional
> > constructs to achieve it. In fact, I've used goto in a few places to
> > tidy up the code..
> 
> If you need to use it to clean up a single function. It's an obvious sign
> that the function is too complicated. In 10 years of writing complicated
> code I have yet to see a single place where it is actually required.

Required? No. Useful? Yes.

Too often I've seen people push the "cleanup" stuff into another function,
thinking that bit of refactoring was a good idea. Thing is, if they didn't
document that the function is private just for another function, some other
coder will come along later, see the function, and think its fine for them
to use (solving their immediate problem.) This leads to badness in the
future.

It took me quite a while to get over the "goto is evil, never ever use it"
koolaid. But then, in C++, you should be using exceptions, not weird
flow control tricks. :)



Adrian

-- 
- Xenion - http://www.xenion.com.au/ - VPS Hosting - Commercial Squid Support -
- $25/pm entry-level VPSes w/ capped bandwidth charges available in WA -

Reply via email to