[Coco] GOTO and code maintainability

Michael Furman n6il at ocs.net
Mon Sep 7 11:42:48 EDT 2009


On Sep 7, 2009, at 7:44 AM, Mark McDougall wrote:

> 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.
>
> Regards,
>

I happen to have copies of Dijkstra's original letters to  
Communications of the ACM on this subject.  They are interesting  
reads, even if dated:

Read this first: http://www.ocs.net/~n6il/dij68-2.pdf  "Go To  
Statement Considered Harmful"
Then this: http://www.ocs.net/~n6il/dij68.pdf "Go To Statement  
Reconsidered"



More information about the Coco mailing list