[openbeos] Re: Open-beos-cvs digest, Vol 1 #1587 - 8 msgs

  • From: Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Thu, 15 May 2003 11:11:56 +0200 (MEST)

On Wed, 14 May 2003, Tyler Dauwalder wrote:

> On 2003-05-14 at 17:03:19 [-0700], Axel Dörfler wrote:
> >
> > Bill Hayden just did the following to Shape.cpp:
> >
> > > Log Message:
> > > Conform to new scoping rules for variables defined in a for loop
> > >      status_t err = BArchivable::Archive(archive, deep);
> > > +    int32 i;
> > > @@ -186,7 +187,7 @@
> > > -    for (int32 i = 1; i < data->ptCount; i++)
> > > +    for (i = 1; i < data->ptCount; i++)
> > >          archive->AddPoint("pts", data->ptList[i]);
> >
> > Have I missed the evolution? What new scoping rules? Did M$ win? I
> > always hated VC++ for that...
>
> Well, hold on a second. If you look at the entire function in
> Shape.cpp, you'll notice the original code was something like this:
>
> -------------------------------------------------------------
> for (int32 i = 1; i < data->ptCount; i++)
>     archive->AddPoint("pts", data->ptList[i]);
>
> [...misc. stuff with no new declarations of variable i...]
>
> for (i = 1; i < data->opCount; i++)
>     archive->AddInt32("ops", data->opList[i]);
> -------------------------------------------------------------
>
> That certainly seems like it should be illegal (to me at least). The
> new code now looks like:
>
> -------------------------------------------------------------
> int32 i;
>
> for (i = 1; i < data->ptCount; i++)
>     archive->AddPoint("pts", data->ptList[i]);
>
> [...misc. stuff with no new declarations of variable i...]
>
> for (i = 1; i < data->opCount; i++)
>     archive->AddInt32("ops", data->opList[i]);
> -------------------------------------------------------------
>
> Feels much better to me, given the second loop. :-)

Definately.

BTW, I hope, this is just another bug of our ancient gcc (at least the
GeekGadgets one) -- it issues a warning when one declares the same
iteration variable in a subsequent loop, like:
  for (int i = ...) {}
  for (int i = ...) {}

Very annoying. Just another of innumerable bugs...
*sigh*

CU, Ingo

Other related posts: