Re: continue statement

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

On Wed, 21 Jun 2000 12:39:26 +0200, <tone.skoda at SIOL.NET> wrote:

>euphoria should have continue statement like in c to be used in while/for
>loops.
>
>with continue statement you go to beginning of loop when you dont want
>statements after continue to be executed.
>in euphoria now you must define switch, and have to check it every time in
>loop, which slows it down
>
>example:
>euphoria:
>
>while 1 do
>if p then
>    k+=1
>    switch=1
>end if
>
>if switch=1 then --this has to be checked every time
>    ...do actions
>else
>    switch=0
>end if
>end while

I'm not sure I follow the above example.  Can switch be something other
than 1 or 0?  If p is non-zero, switch is set to 1 so we 'do actions'.  If
p is zero then switch *might not* be equal to 1 so we set it to zero.  (If
p is zero and switch is zero, then we are stuck in a loop that keeps
setting switch to zero... that part doesn't make sense.)

But I do follow what you are saying in the example below.  On the other
hand, couldn't you accomplish the same thing by doing something like:

while 1 do
  if p then
    k += 1
  else
    ...do actions
  end if
end while

Am I missing something obvious here?

  Brian

>--------------------------------------------------------------------------
>
>
>with continue statement, like in c:
>
>while 1 do
>if p then
>    k+=1
>    continue --goes to top of loop
>end if
>
>...do actions
>end while

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

Search



Quick Links

User menu

Not signed in.

Misc Menu