mozilla/rust — Issue #1906: Add an infinite-loop construct
Author: catamorphism
Created: 2012-02-26 18:58:23+00:00
State: open
Labels: A-typestate, B-RFC, E-easy

This idea has come up before, but #1905 reminded me that we never really reached agreement on it. I propose adding a new looping construct, ```forever [block]```, that has the same semantics as ```while (true) [block]```. The reason to add a special construct would be to allow typestate to recognize that infinite loops run forever, and not yield spurious-looking errors (see #1905 for an example) about functions not returning a value. The current workaround is to do ```while (true) { ... }; fail "Unreachable";```, which isn't terribly burdensome, but is annoying.

I realize we're trying not to add stuff, but this issue seems to be a source of confusion, and ```while (true)``` loops seem to be pretty common.