in reply to Infinite Loop Question

I might be missing something here, but why are we not using the traditional:
while(1){... do stuff...}
This is what I use when I write deamons. Maybe it is bailing out due to lack of available memory?

Replies are listed 'Best First'.
Re^2: Infinite Loop Question
by ikegami (Patriarch) on Nov 08, 2011 at 23:13 UTC
    while (1) and for (;;) (which is also quite traditional) result in the same code.
    $ perl -MO=Concise,-exec -e'for (;;) { f() }' 1 <0> enter 2 <;> nextstate(main 3 -e:1) v:{ 3 <{> enterloop(next->8 last->9 redo->4) v 4 <;> nextstate(main 1 -e:1) v 5 <0> pushmark s 6 <#> gv[*f] s/EARLYCV 7 <1> entersub[t3] vKS/TARG,1 8 <0> unstack v -e syntax OK $ perl -MO=Concise,-exec -e'while (1) { f() }' 1 <0> enter 2 <;> nextstate(main 3 -e:1) v:{ 3 <{> enterloop(next->8 last->9 redo->4) v 4 <;> nextstate(main 1 -e:1) v 5 <0> pushmark s 6 <#> gv[*f] s/EARLYCV 7 <1> entersub[t3] vKS/TARG,1 8 <0> unstack v -e syntax OK $ diff -u \ <( perl -MO=Concise,-exec -e'while (1) { f() }' 2>&1 ) \ <( perl -MO=Concise,-exec -e'for (;;) { f() }' 2>&1 ) \ && echo same same
Re^2: Infinite Loop Question
by joeymac (Acolyte) on Nov 09, 2011 at 12:37 UTC

    No particular reason why I used

     for(;;) {...}

    instead of

     while(1) {...}

    It is my understanding that the two are pretty much interchangable.