While reading through the great online PHP tutorials of Paul Hudson he said
Perhaps surprisingly, infinite loops can sometimes be h
I think a point is being missed... there aren't really infinite loops (you would be stuck in them forever), rather while(true){...}
and co are useful when you have non trivial exit conditions (e.g. those coming from a third-party library, or a limit which would take a lot of time to calculate but can be worked out incrementally inside of the loop, or something relying on user input).
It shouldn't be surprising that not every loop can be concisely stated as a for
, while
or do
loop without using break
.