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

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

by toma (Vicar)
on Jan 04, 2002 at 05:56 UTC ( #136179=note: print w/ replies, xml ) Need Help??


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

For infinite loops I like

while(1>0) { # do stuff }
This makes it really obvious that I mean 'forever'. Some of my co-workers have said that it really jumps out at them.

It should work perfectly the first time! - toma


Comment on Re: do/redo or for(;;): what's Kosher?
Download Code
Replies are listed 'Best First'.
Re: Re: do/redo or for(;;): what's Kosher?
by Anonymous Monk on Jan 04, 2002 at 12:35 UTC
    Personally, I just omit the condition all together:
    while() { ... }
    Not sure why it works, but it does.
      This is why it works:
      2;0 juerd@ouranos:~$ perl -MO=Deparse -e'while () { print "1\n" }' for (;;) { print "1\n"; } -e syntax OK


      Many people aren't going to like this:
      2;0 juerd@ouranos:~$ perl -MO=Deparse -e'while (1) { print "1\n" }' for (;;) { print "1\n"; } -e syntax OK


      2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Re: Re: do/redo or for(;;): what's Kosher?
by robin (Chaplain) on Jan 04, 2002 at 19:39 UTC
    Along similar lines, I sometimes use
    until (2 + 2 == 5) { ... }
    which evokes eternity beautifully, in my mind.
      Reminds me of a friend of mine (Hendrix fan), who always uses
      
        if (6==9)
      
      as a break condition. Very cool, IMO.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2015-07-30 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls