Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: do/redo or for(;;): what's Kosher?

by dragonchild (Archbishop)
on Jan 03, 2002 at 22:42 UTC ( #136033=note: print w/replies, xml ) Need Help??

in reply to do/redo or for(;;): what's Kosher?

I personally don't like that idiom, because it's not obvious to me that it's an infinite loop. For that, I would prefer while (1) or something along those lines. (Actually, I've never had to program an eternal loop before. *shrugs*)

Of course, I've also never used redo, so the idiom isn't very familiar to me.

We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re: do/redo or for(;;): what's Kosher?
by runrig (Abbot) on Jan 03, 2002 at 23:03 UTC's not obvious to me that it's an infinite loop...

    Its easy to see on a short, simple loop, but on longer more complex things I just label loops as such (or whatever they function as):

    # I usually include the label in the loop control statement # so everything's immediately obvious, but I omit them here. LOOP: { last if $something; ... redo; } INFINITELOOP: { ... redo; } FILTER_FOO_LOOP: { next if foo(); ... redo; } FOO_SWITCH: { foo() and last; foobar() and last if something(); }
Re: Re: do/redo or for(;;): what's Kosher?
by AidanLee (Chaplain) on Jan 03, 2002 at 23:16 UTC
    The one time I've used redo is when I've wanted to do just that -- redo something that I was only expecting to have to do once, but that messed up. Connecting to UPS's shipping services, some of the possible errors returned are 'transient' and can be fixed by simply resending the quote request. So i have something along the lines of:
    "redo SUBMIT_REQUEST if $transient_error"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://136033]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2017-01-19 05:08 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (168 votes). Check out past polls.