[Coco] GOTO and code maintainability

Mark McDougall msmcdoug at iinet.net.au
Mon Sep 7 10:44:44 EDT 2009

Aaron Banerjee wrote:

> Has anyone else run into this type of "GOTO intolerance" while programming?

At uni we were introduced to programming using Pascal, and in those days 
"GOTO" was a 4-letter word. I graduated to C and for many years it was 
drummed into me that the aforementioned was to be avoided at all costs.

To this day, you could probably count the number of times I've used "GOTO" 
(in C) on one hand. At one point I was even resorting to using a big "if 
(1)" statement with "break"'s littered within for exiting on error 
conditions. I thought it was clever - until I realised that (a) it didn't 
work with nested conditional structures (for,while,etc) and (b) it was 
actually _clearer_ to the reader using "goto"!

[Of course this particular scenario is somewhat moot now with proper 
exception handling in modern languages, but that's beside the point.]

I've learned that there's many ways to skin a cat, some better than others, 
but to say "never" is probably foolish (with one exception - I'll _never_ 
use Java for anything!). OK, 2 exceptions - add C# to that list.


|              Mark McDougall                | "Electrical Engineers do it
|  <http://members.iinet.net.au/~msmcdoug>   |   with less resistance!"

More information about the Coco mailing list