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=0.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,45c6e2680274292d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Received: by 10.216.61.65 with SMTP id v43mr1710051wec.6.1343094419236; Mon, 23 Jul 2012 18:46:59 -0700 (PDT) Path: ge7ni52434390wib.0!nntp.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!border1.nntp.ams2.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!ctu-peer!news.nctu.edu.tw!goblin1!goblin2!goblin.stu.neva.ru!news.internetdienste.de!news.tu-darmstadt.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Labeled exit within generalized labeled loop not allowed? Date: Mon, 16 Jul 2012 15:03:19 +0300 Organization: Tidorum Ltd Message-ID: References: <5003dffc$0$291$14726298@news.sunsite.dk> Mime-Version: 1.0 X-Trace: individual.net kzlZS1wfAoEo9CiZl2YozA7sG/5eEeFj7CjFo1ip4ZUilRwgZv8i+/7T/alFLeHRw7 Cancel-Lock: sha1:nAUXoYeQk+1eHpbYq5L6skK8YaI= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Date: 2012-07-16T15:03:19+03:00 List-Id: I forgot to state my conclusion explicitly (at the end, below): On 12-07-16 13:33 , Niklas Holsti wrote: > On 12-07-16 12:33 , Thomas L�cke wrote: > >> I would've thought that labeled exits were something that were widely >> used. > > A data point on this: > > I scanned an Ada 2005 project of mine. It has 893 loops but only 35 > labeled exit statements. These are always on large, complex loops, > sometimes nested loops where the exit leaves the outermost loop from an > innner loop. When these loops are traversing a data structure, the > structure is usually dynamic (e.g. a work-list) that can shrink and grow > during the execution of the loop. > > This project has many loop exits from small traversal loops of fixed > data structures. These loops could use the generalized loop syntax, but > the loops are small and usually not nested, so they are not named. > > To me, the generalized loop syntax suggests that the loop should be > executed for all the elements in the container, that the amount of data > in the container does not change during the loop, and that the traversal > order is not important. I know that the order is defined; I am talking > about my impression while reading the program. I'm not sure if data can > be added to or removed from a container during a generalized iteration > over the container; would that be "tampering"? The conclusion is that I (as one example of an Ada programmer) usually would not code an exit statement (whether labeled or unlabeled) in a simple loop that uses the generalized loop syntax, because then the loop would not process all the elements in the container. Vice versa, I would also be unlikely to use the generalized loop syntax for a loop that needs a labeled exit statement, because such a loop is likely to be more complex and dynamic than seems suitable (to me) for the generalized loop syntax. Moreover, an exit statement usually means that iteration order is important, which I (subjectively) do not associate with the generalized syntax. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .