[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: upcoming changes in Lua 5.2
- From: "Leo Razoumov" <slonik.az@...>
- Date: Wed, 27 Feb 2008 11:16:02 -0500
On 2/27/08, Alexander Gladysh <agladysh@gmail.com> wrote:
> > > for (int i = 0; i < 10; ++i)
> > > {
> > > if (i % 2)
> > > {
> > > continue;
> > > }
> > > printf("odd %d", i);
> > > }
> > >
> > > I treat continue in the first example as an another exit from the loop
> > > iteration.
> >
> > No it is not! The only exit point from the "for" loop above is the
> > condition "i<10".
> > "continue" simply causes to skip printf statement.
>
>
> The only exit point from the *loop* is the condition "i < 10".
> But continue is an extra exit point from a *single iteration* of the
> loop -- that is, the code between its {}.
>
An "exit point" is defined as a point in the program that leaves
certain scope such as function, loop, switch statement, etc. In C/C++
"return", "break", "goto" qualify as such but "continue" generally
does not. In your example "continue" does leave the scope of
"if"-statement but not the "for" loop.
--Leo--
(my last post on this topic)
- References:
- Location of a package, Ignacio Burgueño
- Re: upcoming changes in Lua 5.2 [was Re: Location of a package], Roberto Ierusalimschy
- Re: upcoming changes in Lua 5.2 [was Re: Location of a package], Asko Kauppi
- Re: upcoming changes in Lua 5.2 [was Re: Location of a package], Doug Rogers
- Re: upcoming changes in Lua 5.2, Miles Bader
- Re: upcoming changes in Lua 5.2, Alexander Gladysh
- Re: upcoming changes in Lua 5.2, Leo Razoumov
- Re: upcoming changes in Lua 5.2, Alexander Gladysh
- Re: upcoming changes in Lua 5.2, Leo Razoumov
- Re: upcoming changes in Lua 5.2, Alexander Gladysh