[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: I'd give my right arm for a continue statement
- From: GrayFace <sergroj@...>
- Date: Sun, 23 Jan 2011 17:41:16 +0600
On 22.01.2011 15:23, steve donovan wrote:
The best answer is by Roberto, quoted by David Manura in this post:
That's a real deal. I find 'continue' and 'break N' both very useful in
certain situations. I think there also were situations where I wanted
'continue N' that would act similar to 'break N'. 'Redo' and 'continue
n' with 'n' indicating the number of iterations to skip are useful too...
Now, to the readability.
The first thing is that 'break' and 'continue' must be separate keywords
for the sake of readability.
I don't think 'break N' would worsen readability much compared to
standard 'break'. You already have to get over one or two ends of IF's
now to find the end of the loop. In many cases nested loops come one
right after another and 'break N' would be almost as readable as simple
'break'. Actually, when 'break N' is needed, it improves readability,
because work-arounds used instead of just shadow the logic.
I like the suggestion of labeled loops, it's certainly more readable,
but it's a serious syntax extension. I gravitate towards something like
for y = 1,10 do
for x = 1, 10 do
The stringy labels should prevent any collisions with operators that follow.
Overall, I consider simple 'continue' to be a safe ground. Any readable
more sophisticated solution I can think of would still include the
Sergey Rozhenko mailto:email@example.com