Re: continue statement

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Thu, 22 Jun 2000 05:18:50 -0400, Derek Parnell wrote:

>An example...
>
>---
>integer NextIter
>constant DoWork = 0
>constant SkipWork = 1
>while 1 do
>  NextIter = DoWork -- Reset flag.
>
>  if action0() then exit end if
>  if P then
>    if Q then
>      action1()
>      if R then
>        NextIter = SkipWork -- Set flag to skip further processing.
>      end if
>    else
>      action2()
>      NextIter = SkipWork -- Set flag to skip further processing.
>    end if
>
>    if NextIter = DoWork then -- If okay, do more processing
>      action4()
>    end if
>  end if
>
>  if NextIter = DoWork then -- If okay, do more processing
>    action3()
>  end if
>end while
>
>
>--- However with a "continue" or "next" statement...
>
>while 1 do
>  if action0() then exit end if
>  if P then
>    if Q then
>      action1()
>      if R then
>        next -- Start next iteration
>      end if
>    else
>      action2()
>      next -- Start next iteration
>    end if
>
>    action4()
>  end if
>
>  action3()
>end while
>
>--- Of course, this is a simple example but in the real world, they can get
>a lot more verbose.

I think you'd have to come up with something more complex to convince me
that this is really useful.  I think the following loop does the same thing
and I don't think it's any more or less confusing than haveing a 'next'
or 'continue':

while 1 do
  if action0() then exit end if
  if P then
    if Q then
      action1()
      if not R then
        action4()
        action3()
      end if
    else
      action2()
    end if
  end if
end while

-- Brian
-- ( playing the role of a skeptic; and I'm sure somebody will come up with
an example that will either convince me or will be so complex that I won't
want to try rewriting it. 8^)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu