lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Jun 19, 2009 at 1:00 PM, Peter Cawley <lua@corsix.org> wrote:
>
> On Fri, Jun 19, 2009 at 4:51 PM, Hisham<hisham.hm@gmail.com> wrote:
> > This would make 'continue' mean "jump to the top", and would be
> > consistent with 'while' and 'for'.
>
> In C, in a 'while', 'continue' jumps the remainder of the loop body
> and to the condition. The condition is at the top of the source, but
> it's not the top of the loop body. Again, in C, in 'for', 'continue'
> jumps to the counting expression and then onto the condition. I tend
> to visualise the counting expression at the bottom of the loop body,
> even though it is specified above the loop body. Thus the norm is for
> 'continue' to jump to the condition, and skipping the condition for a
> 'continue' in a 'repeat' would break this norm.

I understand. When I said "would be consistent with 'while' and 'for'"
I meant that a single rule could apply to *Lua's* 'repeat', 'while'
and 'for' consistently. We can't use C's 'continue' semantics anyway
due to Lua's 'repeat' weirdness, so I'd rather have something that
works without having to special-case 'repeat' -- I think the simple
semantics "jump to the top of the construct" (where the test is, in
'while' and 'for', and isn't in 'repeat') would satisfy that.

-- Hisham