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!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx13.iad.POSTED!not-for-mail From: Brad Moore User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Strange error References: <713608f7-d46e-4b73-a34e-552d1b978d2c@googlegroups.com> <01fc779f-e274-4515-a88f-144d515d323f@googlegroups.com> <3fa7d4c4-f9fe-4d00-9034-a348802087a9@googlegroups.com> <87iofx9d2r.fsf@adacore.com> In-Reply-To: <87iofx9d2r.fsf@adacore.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1422105251 68.145.219.148 (Sat, 24 Jan 2015 13:14:11 UTC) NNTP-Posting-Date: Sat, 24 Jan 2015 13:14:11 UTC Date: Sat, 24 Jan 2015 06:14:15 -0700 X-Received-Bytes: 2223 X-Received-Body-CRC: 3759113171 Xref: news.eternal-september.org comp.lang.ada:24726 Date: 2015-01-24T06:14:15-07:00 List-Id: On 15-01-23 06:34 PM, Bob Duff wrote: > "Randy Brukardt" writes: > >> "Laurent" wrote in message >> news:3fa7d4c4-f9fe-4d00-9034-a348802087a9@googlegroups.com... >> ... >>> How do you professionals prevent such stupid errors? I am just a noob and >>> playing >>> a bit around so it has no impact on anything. >> >> You don't (or at least, I don't). I seem to write loops that don't loop >> (forgot the P := P.Next) all the time. > > "don't loop"? That loops too much. ;-) > > I tend to write the boilerplate first: > > while P /= null loop > > P := P.Next; > end loop; > > Then go back and fill in the body of the loop. So I don't usually > make that particural mistake. Anyway, I think GNAT will give a warning > about that. > > But in Ada 2012, we have iterators, which largely solves the problem. > Put all your eggs in one basket, and if the iterator works, then all > the myriad "for" loops around the code will work. Or in Ada 2005, you can use the Iterate primitive of the containers. Then you don't need to write that boilerplate either, as it is already done for you. Given the choice though, Ada 2012 iterators provides the preferred approach. Brad