Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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.


Comment on Re: do/redo or for(;;): what's Kosher?
Download Code
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"
Re: Re: do/redo or for(;;): what's Kosher?
by NodeReaper (Curate) on Jan 03, 2002 at 23:17 UTC

    Reason: (AidanLee) duplicate

    For more information on this node visit: this

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2014-10-23 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (123 votes), past polls