lua-users home
lua-l archive

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


Mark Hamburg <mark@grubmah.com> writes:

> On Feb 17, 2010, at 9:39 AM, David Kastrup wrote:
>
>> By the way, it would also be possible to just use "repeat" which already
>> is a reserved word.  If its use is restricted to the same places where
>> "break" and "return" are allowed, I don't think that there is syntactic
>> ambiguity.
>
> Maybe not with a little extra lookahead, but if you see:
>
> 	if not_ready() then repeat
>
> What are you in the midst of parsing?

Depends on whether the next token is "end".  I think that something like

repeat
  dothis
  dothat
  if something then repeat end
  dothis
until condition

is pretty legible.

Also

while condition do
  dothis
  dothat
  if something then repeat end
  dothis
end

does not look all too confusing to me.  And it accomplishes both the
goal to make clear that "repeat" is not "continue" and not to need
another keyword.

Regardless of which keyword is used, I repeat my proposal to make
"continue" under whatever name resume at the top of a repeat loop, not
the condition.

That not just avoids the scope problems, but is quite more useful in
practice.

-- 
David Kastrup