At 09:55 AM 7/14/2005, Lloyd Sartor wrote:
My opinion is that the goto statement can be useful in error handling situations, particularly when parsing data. This removes the rarely-executed error handling code from the expected, normal processing code. This makes the normal code more cohesive, understandable, and maintainable (IMO) because it remains sequential, uncluttered by unnecessary indentation, braces, etc. Of course, Perl provides synonyms for 'goto' in these scenarios (last, continue).
If you try it, you'll find that using eval {} and die() is much better for error handling. Especially since you can die() in arbitrarily nested subroutines. Even C (at least C++) has a similar behavior via the "try" construct.
I think that it's absurd to claim that work done by Edsger W. Dijkstra, one of the most brilliant minds in Computer Science, has been discredited by someone with lesser credentials. The only case where I think that a 'goto' is justified is when no other alternative is available in the language you're using (usually a failing of the language) that is as computationally efficient, and computational efficiency is a major issue (it usually isn't). I've used it, but only in a very few cases.
Personally (and I hope I'm not starting a spam war here), I feel the same way about last and continue, which usually indicate a not-too-well thought out loop condition. We have 101,396 lines of production code with 2 goto's, 0 continue's and 7 last's.
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
