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!.POSTED!not-for-mail From: Bob Duff Newsgroups: comp.lang.ada Subject: Re: Strange error Date: Fri, 23 Jan 2015 20:34:04 -0500 Organization: A noiseless patient Spider Message-ID: <87iofx9d2r.fsf@adacore.com> References: <713608f7-d46e-4b73-a34e-552d1b978d2c@googlegroups.com> <01fc779f-e274-4515-a88f-144d515d323f@googlegroups.com> <3fa7d4c4-f9fe-4d00-9034-a348802087a9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b517e9a5d71ce0b52e2e81512ffb00e4"; logging-data="7778"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MRgtqYjcLXlXYnzTub6Gb" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:4/JaovAlImh75IiiKd/qPw9zzII= sha1:urnkgTqFWonfYiZn1CClpj9hlbg= Xref: news.eternal-september.org comp.lang.ada:24725 Date: 2015-01-23T20:34:04-05:00 List-Id: "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. - Bob