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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: syntaxic exploration Date: Fri, 22 Dec 2017 17:45:22 -0600 Organization: JSA Research & Innovation Message-ID: References: <0d33e631-e63d-4346-ac95-5eec72127f4f@googlegroups.com> Injection-Date: Fri, 22 Dec 2017 23:45:25 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="8563"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:49598 Date: 2017-12-22T17:45:22-06:00 List-Id: wrote in message news:b81c7f6f-dda7-4cd1-a9c6-953d0d30e7d4@googlegroups.com... ... > Otherwise, one has to write a while loop, which is a bit awkward. > > Position : Cursor := Cursor1; > > Iteration_Loop : > loop > List (Position) := ... > exit Iteration_Loop when Position := Cursor2; > Next (Position); > end loop; This works, of course. > One can almost do this with the current containers, with Ada 2012 > iterator syntax because they generally > have an Iterate primitive that accepts a start cursor. > > eg. > > for I in List.Iterate(Start => Cursor1) loop > List (I) := ... > end loop; This is true, too. But you just need to exit the loop at the end cursor to get the semantics you want: for I in List.Iterate(Start => Cursor1) loop List (I) := ... exit when I = Cursor2; end loop; Ada doesn't care what kind of loop you use an exit in! If there was to be a complaint here, it's that you can't easily use the element form ("of") with an ending cursor (because the cursor has to be explicit). But it seems weird to me to want to use cursors and yet hide them at the same time. Conclusion: There isn't a need for an explicit "ending cursor", because an exit works fine for that in the cursor form. There still might be some sort of consistency argument, but we didn't add it originally since the exit is so easy to use for ending a loop "early". Randy.