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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.36.89.146 with SMTP id p140mr2974751itb.35.1515198406489; Fri, 05 Jan 2018 16:26:46 -0800 (PST) X-Received: by 10.157.81.198 with SMTP id d6mr210934oth.6.1515198406286; Fri, 05 Jan 2018 16:26:46 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!i6no530748itb.0!news-out.google.com!b73ni1726ita.0!nntp.google.com!i6no530745itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 5 Jan 2018 16:26:45 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:193:4101:1b33:94fa:7d1b:bdc6:d9f5; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA- NNTP-Posting-Host: 2601:193:4101:1b33:94fa:7d1b:bdc6:d9f5 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7b8a1da2-c405-4cbc-9c0b-1fef804c9239@googlegroups.com> Subject: Re: stopping a loop iteration without exiting it From: Matt Borchers Injection-Date: Sat, 06 Jan 2018 00:26:46 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 386195449 X-Received-Bytes: 3297 Xref: reader02.eternal-september.org comp.lang.ada:49775 Date: 2018-01-05T16:26:45-08:00 List-Id: I would like to also put my voice in for a 'next [when condition]' statemen= t. It is also my opinion that in some cases it is more readable. I would = avoid 'continue' only because it is a C term. The use of 'goto' in a loop = to act like a next by jumping to the END of the loop seems more like a hack= and I agree with the sentiment that it adds more confusion for the reader. Regarding performing a sequence of statements conditionally after a loop co= mes up quite a bit in my experience. In our proprietary language we have a= loop...then...end loop construct. The 'then' block executes when the loop= terminates normally (not terminated by an 'exit'). This can be useful whe= n you want to do some action following the loop only when the loop runs 'cl= eanly' and it avoids having to create a Boolean flag variable to set in the= loop with the addition of an 'if' statement and then have to test the flag= following the loop with another 'if' block. A similar situation occurs frequently with exceptions. I would like to see= a 'finally' block added after the 'when' conditions that runs after any ha= ndler is run. begin ... exception when EX1 =3D> ... when EX2 =3D> ... when others =3D> ... finally ... end; This would allow programmers to handle common cleanup operations that would= otherwise have to be duplicated in every exception case. This is mostly u= seful if the code was going to re-raise the exception or return control to = the caller in the exception handler. Control would be returned to the call= er after the 'finally' block if it exists otherwise the program flow behave= s as it does now. These three examples, 'next', loop...'then'...end, 'finally', all allow the= programmer to produce constructs without having to introduce extraneous va= riables, blocks, or sub-routines to track state which, in my opinion, can o= ften make the code more difficult to read.