From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b8b8a54001adc4d2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!news.mv.net!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Possible Ada deficiency? (goto) Date: 15 Jan 2005 12:34:59 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1104516913.718856.94090@z14g2000cwz.googlegroups.com> <1104544963.930877.75170@c13g2000cwb.googlegroups.com> <1104595073.731663.180100@c13g2000cwb.googlegroups.com> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1105810499 28882 69.38.147.31 (15 Jan 2005 17:34:59 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 15 Jan 2005 17:34:59 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:7821 Date: 2005-01-15T12:34:59-05:00 List-Id: Peter Hermann writes: > Robert A Duff wrote: > > The main thing I'm thinking about is that goto labels are implicitly > > declared. The Pascal rule requires an explicit label declaration. > > That makes the code more readable, because you can see up front > > that "gotos lurk below", which is a useful thing to know. > > maybe > > > Even if you think the extra syntactic overhead is annoying, it can't be > > *very* annoying, because people don't write a lot of gotos. > > yes. I was astonished after changing from Fortran to Ada > when I detected to never need any goto. > There are rare cases where a goto is useful. > (I am assuming you do not ban goto at all) True. > E.g. automatic translation from Fortran spaghetti into Ada. > The increase of workload of the translator is neglectable > (when translator=machine, annoying when man) > but the resulting code would be cluttered with label declarations, > which IMHO are of no added value. Well, if I were writing a Fortran-to-Ada translator, it would be smart enough to generate nearly-goto-free Ada. At least, if the Ada code is intended to be read by humans. > > Also, this rule makes the language a little bit harder to learn, because > > no > > > goto labels don't behave like most everything else in the language, > > which *do* have to be explicitly declared. > > > > How many Ada programmers know that the following silly example is > > illegal: > > > > procedure P is > > begin > > for Mumble in 1..10 loop > > missing statement in loop No. There's a null statement. > > <> -- Illegal! > > null; > > end loop; > > end P; procedure P is --(1) begin for Mumble in 1..10 loop <> --(2) null; end loop; end P; Here's why the above is illegal: There is an implicit declaration of label Mumble at that place marked "--(1)". At the place marked "--(2)", this this declaration is not directly visible, because it is hidden by the loop parameter Mumble. Thus, the reference to Mumble at "--(2)" is illegal. That's just plain weird. > > but the following equally silly example is legal: > > > > procedure P is > > begin > > <> > > why not allow a practical "start over"? > Although my personal taste is to avoid goto_s > I welcome this syntactical feature for the comfort of the programer > in the sense of "let_it_be". > > > for Mumble in 1..10 loop > > null; > > end loop; > > end P; > > > > and can explain why? > > > > Compiler writers have to work hard to get those little details exactly > > once done, benefit thousandfold. Thousand times zero = zero. > > right, and it's of zero benefit to programmers. > Returning to my precious and almost never used goto : > It is carved in stone and I like it the way it is :-) Yes, it's carved in stone. > > If my passengers bought tickets from New York to Boston, I don't like to > > have a rule saying I have to drive the bus via Los Angeles! ;-) > "I" (-: not "they" :-) > > anyway: thank you for the good laugh which brightens the day. :-) - Bob