[Coco] GOTO and code maintainability

Robert Gault robert.gault at worldnet.att.net
Mon Sep 7 11:47:30 EDT 2009

Aaron Banerjee wrote:
> All of us have at least at one point in time either used, or tried to 
> figure out code containing GOTO statements.  In a recent programming 
> environment I was in, GOTO (or it's equivalent in whatever language we 
> happened to be programming) was expressly forbidden -- no exceptions no 
> matter what.
> Just to be an irritant, I chucked a single GOTO (to make a polling loop) 
> in a relatively simple program, which totally confused my colleagues.
> Given that it isn't abused, I don't see why GOTO makes code any less 
> maintainable than other obviscation techniques, such as polymorphism 
> (which, while useful, if abused can lead to very multiple inheritance or 
> exception-based program control.  At least GOTO tells you where it is 
> going....
> Has anyone else run into this type of "GOTO intolerance" while programming?
>                           - Aaron

This type of code is usually referred to as spaghetti code with all the 
snarls implied in the adjective.

The "main" academic objection in most languages probably is that 
students typically leave loops via a GOTO. That can be a disaster in 
some languages as the loop structure is not removed.

More information about the Coco mailing list