comp.lang.ada
 help / color / mirror / Atom feed
From: Brad Moore <brad.moore@shaw.ca>
Subject: Re: Strange error
Date: Sat, 24 Jan 2015 06:14:15 -0700
Date: 2015-01-24T06:14:15-07:00	[thread overview]
Message-ID: <DUMww.1242998$Q61.925388@fx13.iad> (raw)
In-Reply-To: <87iofx9d2r.fsf@adacore.com>

On 15-01-23 06:34 PM, Bob Duff wrote:
> "Randy Brukardt" <randy@rrsoftware.com> writes:
>
>> "Laurent" <daemon2@internet.lu> 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


  reply	other threads:[~2015-01-24 13:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-22 21:46 Strange error Laurent
2015-01-23  7:45 ` Egil H H
2015-01-23  8:44   ` Laurent
2015-01-23 20:45     ` Laurent
2015-01-23 21:26     ` Randy Brukardt
2015-01-24  1:34       ` Bob Duff
2015-01-24 13:14         ` Brad Moore [this message]
2015-01-24 19:12           ` Laurent
2015-01-26 21:44         ` Randy Brukardt
2015-01-24  0:47     ` Bob Duff
2015-01-24 19:08       ` Laurent
2015-01-25  9:25     ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox