Breaking Out

James J. Besemer jb at cascade-sys.com
Mon Aug 26 16:37:30 EDT 2002


Bo M. Maryniuck wrote:

>Dijkstra rejects gotos and nameis it worse programming. This is good in 
>Assembler but we have a "break" statement.
>
I am well acquainted with the Dogma.

You should read Knuth's "Structured Programming With GOTOs" to know why 
The Dogma does not always apply and when. Among other things, Knuth 
argues that the introduction of auxilliary variables or other 
contortions to avoid a simple goto is worse than the disease.

Also, we know from our experience with compilers that any structured 
program can be reduced to a program using only tests and gotos (machine 
code).  A lesser known fact is that any arbitrary sphagetti code program 
using only tests and gotos can be automatically transformed into a 
'structured' program using only if and while. That is, 'structured' and 
'spaghetti' styles are isomorphic with one another.

The conclusion from all of this is that including an occasional goto is 
not in and of itself harmful (even Dijkstra only warns against Excessive 
use); nor does avoiding gotos make any guarantee about the readability 
or any other goodness property of the resulting code.  I for one 
certainly have observed some awful code that didn't include gotos.

Regards

--jb

-- 
James J. Besemer		503-280-0838 voice
2727 NE Skidmore St.		503-280-0375 fax
Portland, Oregon 97211-6557	mailto:jb at cascade-sys.com
				http://cascade-sys.com	







More information about the Python-list mailing list