Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by dws (Chancellor)
on Jan 03, 2002 at 22:45 UTC ( #136037=note: print w/ replies, xml ) Need Help??


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

I really like it, and am likely to abandon the for(;;) construct permanently in favor of the above idiom. Should I repent?

One of the tradeoffs you'll need to consider when making this decision is whether readability suffers when your loop gets to be more than an eyefull. A non-loop scope is a common idiom, particularly when the intent it to temporarily localize variables. When I read

{ local $/ = undef; ...
I think to myself, "ah, slurp mode," not "I wonder if this is going to be a loop?" I then read on with a mental context set. But if 15 lines down I enounter last or redo, I have a moment of confusion to work through that wouldn't have been there if the scope had started with   while ( 1 ) {
or   for ( ; ; ) {


Comment on Re: do/redo or for(;;): what's Kosher?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (14)
As of 2014-07-11 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls