Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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
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 making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-12-28 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls