Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!caen!math.lsa.umich.edu!sharkey!tygra!dave From: dave@tygra.UUCP (David Conrad) Newsgroups: comp.lang.pascal Subject: Re: Goto's are okay Summary: GOTO Considered Harmful Keywords: goto, foo, bar Message-ID: <1991Jan27.074528.23487@tygra.UUCP> Date: 27 Jan 91 07:45:28 GMT References: <2802@oucsace.cs.OHIOU.EDU> <1991Jan21.134342@cs.utwente.nl> <2427@bnlux0.bnl.gov> Organization: Moore Software, Detroit, MI Lines: 71 In article <2427@bnlux0.bnl.gov> kushmer@bnlux0.bnl.gov (christopher kushmerick) writes: > >Except for the fact that an exit is just a fancy way of spelling goto, with the >effective label being a automatic label right before the ultimate end. (I do >not know if this is how it is actualy implemented, it may be a return, but >from a logical viewpoint, this is what it is.) > >I like to use gotos within programming blocks, but not between programming >blocks, by programming block, I mean a begin-end pair. > >I also do like the exit construct mentioned above, but I understand that it is >a goto. > >Now: goto work :-) >-- >Chris Kushmerick kciremhsuK sirhC >kushmer@bnlux0.bnl.gov <===Try this one first >kushmerick@pofvax.sunysb.edu Yeah, right, and a repeat until is just a fancy way of spelling goto also, with the effective label at the repeat, and a if not(until_expr) then goto at the end, where until_expr is the conditional which follows the until. For that matter, while expr do.... I hope you see what I'm getting at. All structured programming constructs can be emulated with goto's, and can be thought of etc. But they have the advantage that the compiler does the work for you so you can't screw it up by adding/subtracting lines. That's the difference between structured and spaghetti code. If this isn't obvious, consider the following examples. If it is, press n. procedure foo; label done; begin if errorTest then goto done; done: end; ---------- procedure foo; label done; begin if errorTest then goto done; done: bar; (* This call was adding, breaking the logic *) end; ---------- procedure foo; (* One without goto's *) begin if errorTest then exit; end; ---------- procedure foo; begin if errorTest then exit; bar; (* This time the addition of the call to bar breaks nothing *) end; I'd like you all to know I had to shell out and spend some time with the online help to figure out the syntax of label's and goto's. Never used one outside of BASIC and FORTRAN, and never will. -- David Conrad | label hell; dave@ddmi.com | goto hell; -- = CAT-TALK Conferencing Network, Computer Conferencing and File Archive = - 1-313-343-0800, 300/1200/2400/9600 baud, 8/N/1. New users use 'new' - = as a login id. AVAILABLE VIA PC-PURSUIT!!! (City code "MIDET") = E-MAIL Address: dave@DDMI.COM