[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: continue/repeat...until false dichotomy
- From: Matthew Wild <mwild1@...>
- Date: Tue, 16 Feb 2010 23:42:24 +0000
On 16 February 2010 22:33, Norman Ramsey <email@example.com> wrote:
> > repeat
> > local t = 0
> > if cond then continue end
> > local t = 1
> > ...
> > until t == 0
> > Then the two t are actually different variables (in the current
> > implementation), and it's not clear to which incarnation the
> > comparison refers.
> I'm quite alarmed by this problem.
> I was shocked to discover that
> local t = 1
> local t = t + 1
> -- the scope of the inner 't' should end here, but it doesn't
> until t == 1
> loops forever printing 2.
> I would have expected that the condition in the 'until' is outside the
> scope of the loop body, just like the condition in a 'while'.
> In my mind, this is just a mistake in the language design.
Agreed, I'd willingly sacrifice this for "continue". Quite a few
people seem willing to sacrifice repeat...until in its entirety, which
I disagree with however. I've used it a quite few times where it's a
> Questions like this are why every few years I ask Roberto when we are
> going to get a formal semantics for Lua :-)