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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Building an encapsulated library that uses GNAT sockets under Windows Date: Thu, 28 Apr 2016 15:23:09 -0500 Organization: JSA Research & Innovation Message-ID: References: <58a4942a-452a-4f32-b39b-f8f1fdbfe9fb@googlegroups.com> <68353b5d-94dc-4604-bdb1-00b48396ec1b@googlegroups.com> <33e880a1-df5f-450c-89e0-9b1d1a95e12f@googlegroups.com> <6c3cb21b-f729-4599-afb0-793c8b8fc2b8@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1461874990 23705 24.196.82.226 (28 Apr 2016 20:23:10 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 28 Apr 2016 20:23:10 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:30314 Date: 2016-04-28T15:23:09-05:00 List-Id: "Jeffrey R. Carter" wrote in message news:nfrijv$k74$1@dont-email.me... > On 04/27/2016 03:16 PM, Randy Brukardt wrote: >> >> loop >> {some code} >> if something then >> goto Continue; >> end if; >> {more code} >> <> -- Ada 95 requires "null;" here, Ada 2012 does not. >> end loop; >> >> To completely eliminate the goto, one has to use a Boolean variable >> instead, >> or duplicate parts of the loop; both of those obscure what is going on >> more >> than the goto. > > This claim is completely untrue. [Followed by a bunch of true, but irrelevant discussion.] It's completely true, because, of course, the if is likely to be deeply nested inside of other if and case statements. I should probably have said that, but it is so plainly obvious I didn't think anyone would be so silly as to ignore and beat up on a straw man. But of course this is the Internet, where even usually reasonable people enjoy beating straw men... A typical case would be a lexer for numeric literals, where one wants to discard the underscores and keep the other characters. That would look something like: while not End_of_File loop case Next_Char is when '0'..'9' => null; when '+' | '-' => {some code} when 'E' | 'e' => {some code} when '_' => if Last_Char = '_' then Error (...); else goto Continue; -- Skip further processing. end if; when others => exit; -- We've reached the end of the number. end case; {Store the Next_Char into the literal token} <> end loop; To avoid the goto/continue, you'd have to introduce a Boolean, or duplicate the "Store" code, or make the "Store" code into a subprogram, and make duplicate calls on that. None of which is clearer, or faster, than the above code. (Faster matters here as this loop is the third most used of the inner lexer loops, behind comments and identifiers. And a lexer is one of the top CPU users in a typical compiler.) Randy.