Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by dragonchild (Archbishop)
on Jan 03, 2002 at 22:42 UTC ( [id://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
    ...it'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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://136033]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found