Live data from Hacker News

Unconditional loops are unconditionally awesome

brson.github.io

1–10 of 13 posts

Re: Unconditional loops are unconditionally awesome

#5
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").

Re: Unconditional loops are unconditionally awesome

#6
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?

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.

Re: Unconditional loops are unconditionally awesome

#10
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.

Specifying the condition for the loop up front makes me feel more confident about the loop safely concluding once the work is done.

Post reply on HN