[comp.os.minix] No goto's please

terry@sunquest.UUCP (Terry Friedrichsen) (10/03/89)

> tweten@gilmore.nas.nasa.gov (Dave Tweten) writes:
> I hope you are merely overstating you case, Dr. Tanenbaum.  I had
> thought the "No gotos" religion had died, mercifully for the rest of
> us.

I used to make the same kinds of arguments.  As an ex-FORTRANer, the GOTO
was definitely on my list of things that a language "needed" to have.

Then came the black day when the instructor of the computer science
course I was in announced "There will be two programming projects in
this course.  The first WILL be written in C, and the second WILL be
written in Pascal.  AND NO GOTOs!".  Now I thought that dictating the
programming language was unreasonable enough in itself (I can do this
in FORTRAN; leave me alone!), but to prohibit GOTOs was going beyond
the bounds!  But what could I do?

I wrote about 20,000 lines of code for that course, with nary a goto in
sight.  By the end of the semester, I didn't even miss 'em.  That was
10 years ago.  Since then, I have written hundreds of thousands of lines
of code in many complex logical situations (writing compilers, operating
systems, and network implementations), and have NEVER used a single goto.
My organic, pretzel-powered logic constructor now believes they don't
exist, and thus never puts me in a position where I need or even
want one.

This is the wrong forum for this discussion, and it's been beaten to death
in the forums for which it is appropriate, so I'll shut up.  But I wanted
to rebut and put this in front of those many programmers writing MINIX code:

	Dr. Tanenbaum is right:  please, no gotos!

Terry R. Friedrichsen
TERRY@SDSC.EDU  (alternate address; I live and work in Tucson)

(Reply with flames or send them to the above address.  All mail will be
 read, though not necessarily replied to.)

Disclaimer:  My company doesn't read my messages, so it can't possibly
		know what I'm saying!

HBO043%DJUKFA11.BITNET@cunyvm.cuny.edu (Christoph van Wuellen) (10/03/89)

Since terry@SUNQUEST.UUCP mentions the PASCAL programming language in a
recent article, i may add a comment to this discussion:

In C, you never need a goto, since you have the exit() system call and the
return statement. In pure PASCAL there are sitations where a goto might be
appropriate:
- terminating the program after an fatal error (as it is done by exit() )
- leaving a procedure across several other structures (as it is done by
  return)

If you don't want to code a goto in such a situation (in PASCAL), there are
Situtations where the code gets more obscure in my opinion.

Nevertheless, in C there are exit and return which are better than goto's.

Christoph van Wuellen, Bochum.

jbayer@ispi.UUCP (Jonathan Bayer) (10/03/89)

HBO043%DJUKFA11.BITNET@cunyvm.cuny.edu (Christoph van Wuellen) writes:

>Since terry@SUNQUEST.UUCP mentions the PASCAL programming language in a
>recent article, i may add a comment to this discussion:

>In C, you never need a goto, since you have the exit() system call and the
>return statement. In pure PASCAL there are sitations where a goto might be
>appropriate:
>- terminating the program after an fatal error (as it is done by exit() )
>- leaving a procedure across several other structures (as it is done by
>  return)


However, most versions of Pascal do provide an exit procedure, and usually
provide a return procedure.  Some versions also allow the return procedure
to return from several procedures down (this I don't like).


JB
-- 
Jonathan Bayer		Intelligent Software Products, Inc.
(201) 245-5922		500 Oakwood Ave.
jbayer@ispi.COM		Roselle Park, NJ   07204    

jk0@image.soe.clarkson.edu (Jason Coughlin) (10/03/89)

From article <24982@louie.udel.EDU>, by HBO043%DJUKFA11.BITNET@cunyvm.cuny.edu (Christoph van Wuellen):
= In C, you never need a goto, since you have the exit() system call and the
= return statement. In pure PASCAL there are sitations where a goto might be
= appropriate:
= - terminating the program after an fatal error (as it is done by exit() )
= - leaving a procedure across several other structures (as it is done by
=   return)

Gawd, I HATE to add to this stupid discussion, but have you ever used
setjmp and longjmp?  These are a form of goto and they are VERY useful
and are used a lot. 

Can we carry this little discussion in ANOTHER newsgroup?  It is nolonger
relevant, and it's wasting too much space here.
 
--
-- 
Jason Coughlin ( jk0@sun.soe.clarkson.edu , jk0@clutx )
"Every jumbled pile of person has a thinking part that wonders what the
part that isn't thinking isn't thinking of." - They Might Be Giants