comp.lang.ada
 help / color / mirror / Atom feed
From: "gilrain" <john.thile@murraystate.edu>
Subject: Re: "In reverse" in for loop acting weird.
Date: Sun, 29 Sep 2002 14:19:51 -0500
Date: 2002-09-29T14:19:51-05:00	[thread overview]
Message-ID: <2iIl9.81565$5M3.3572108@e3500-atl2.usenetserver.com> (raw)
In-Reply-To: 3D974B39.6000800@acm.org

Thanks for the tips! I'm still learning proper style, so I found these quite
useful. I should have remembered 'range!

John Thile


"Jeffrey Carter" wrote:
> ...
> If the range of Coefficients is -15 .. 15, then your for loop would be
> better written as
>
> for J in [reverse] Coefficients'range loop
>
> In general, when working with arrays, it is rarely necessary to mention
> a magic number more than once. Once the magic number is used to define
> the range of the type or object, attributes, such as 'range above,
> eliminate the need to mention it again.
>
> When you do need to mention a magic number more than once, it's a good
> idea to make it a named number or constant. For example, the 16 in your
> code is a good candidate for this. I suspect it may be
>
> (Result'Length + 1) / 2.
> ...






      reply	other threads:[~2002-09-29 19:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-29 17:28 "In reverse" in for loop acting weird gilrain
2002-09-29 17:59 ` Martin Dowie
2002-09-29 21:15   ` Martin Dowie
2002-09-29 18:31 ` tmoran
2002-09-29 19:17   ` gilrain
2002-09-29 18:49 ` Jeffrey Carter
2002-09-29 19:19   ` gilrain [this message]
replies disabled

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