Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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 chilling in the Monastery: (6)
As of 2018-03-24 18:54 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.