Couldn't you do this in any language? Either write a do while or write a infinite loop with true as condition and then write breaks in the loop itself?<p>That's what I mostly do in java, write a while(true) and then either come back to change the condition or write break in the loop.
One thing I don't know how to do in Python is using while loops to collect results of some other loop that runs at the same time.<p>For example, within the same script, I would have a simulate_magic_numbers function with a loop that produces a sequence of magic numbers continuously for a few hours and returns them once done. Below, I would like to have a while loop that grabs the magic numbers every 10 minutes and plots them.<p>I know how to do it with two separate scripts and saving intermediate numbers to a file, but it would be great to be able to do it within a single Jupiter notebook. However, there doesn't seem to be a straight-forward way of doing it.
The problem is we don't always write perfect code, so if you forget to return or break on any given branch (I.e. in some else statement) you could get stuck in the loop forever. Remember Apple's famous goto fail; SSL bug? Sometimes it's not so easy to eyeball the code and follow the execution flow.<p>Specifying the condition for the loop up front makes me feel more confident about the loop safely concluding once the work is done.
It has its uses but it's pretty low hanging fruit. I also think having the termination conditions in the loop header is much more readable most of the time
I have written very little rust code, but loop is probably the thing I like the least. It requires mutation to be useful in most cases, even for things where you could avoid it. I would much rather have something like scheme's named let (or a decorator to enforce LLVMs "sibling recursion").