lua-users home
lua-l archive

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


GrayFace <sergroj@mail.ru> writes:

> On 23.01.2011 18:42, David Kastrup wrote:
>>> Not to mention all other languages.
>> It has never been a goal for Lua to emulate misfeatures.
>
> What's your reasoning to call this a misfeature? Let's take Pascal as
> an example, since it doesn't have that 'byproduct'. What's bad about
> this in Pascal?
> I think Lua is supposed to be easily understandable, with minimum
> number of gotchas and substandard continue-repeat combination is a
> huge gotcha.
>
>>> My memory may be failing me about the patch, but I think this behavior
>>> is *the* solution and the whole continue-repeat clash is a non-issue.
>> Could you give an example of a repeat-until construct where continue
>> jumping to the evaluation of the loop condition would be a useful thing
>> to have?
>
> That's a hard thing. I rarely use repeat..until and in complex cases I
> tend to use a 'while true' loop. So, no example for now.

The usual thing is something like

repeat
  get some input
  create, maybe process data from it
until the end of processing has been reached, decided by some criterion

Reasons to reloop would be invalid input (output an error message, get
back to top), impossibility to process the data with another prompt.

A premature end of file or final impossibility to process data is a case
for break.  I really can't think of a good case for evaluating the
until-condition when short-circuiting the loop body.

This thing does not need to be called "continue".  "continue" just has
the advantage that people have so far refrained from using it as an
identifier, since it is sort of expected to be on the shortlist of
keywords to be.

-- 
David Kastrup