Very Horrible Question About Goto's

Gaetan Corneau corg at
Wed Apr 19 11:17:21 EDT 2000


> 1) the only valid use of goto's in C I've seen looks like this:
> 	if (bogus)
> 		goto cleanup
> 	do stuff;
> 	return(okay);
> cleanup:
> 	close file handles;
> 	do cleanup
> 	return(error)

There are, at least, two other valid uses:
1) the most important: goto's are used a lot by code generators (it
simplifies writing the generator alot in some cases)

2) in extreme cases, to improve performances.

IMHO, Goto's *are* evil in languages where you can jump around from one
function to another, but they can be useful in some cases. 

My own rules are: 
- don't use goto's

if you HAVE to use goto's:
- don't jump from one function to another (if your language supports it)
- don't jump backward

I was surprised to learn that Python doesn't have a goto statement.
Would it be difficult to add?
   Gaetan Corneau
   Software Developer
   E-mail: corg at                         
"Tu l'as trop écrasé, César, ce Port Salut"

More information about the Python-list mailing list