OT: for (;;) {} vs while (true) {}

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 25 14:54:39 PST 2016


On 25.11.2016 17:38, Kagamin wrote:
> On Friday, 25 November 2016 at 11:10:44 UTC, Timon Gehr wrote:
>> You can just as easily edit the while condition. I use it because
>> "unconditional loop" is less silly than "loop until true is false".
>
> Unconditional loop can be implemented in 3 possible ways :)
> 1. skip it entirely: since there's no condition to check, can't decide
> if should enter at all
> 2. run once: since there's no condition to check, can't decide if should
> repeat - becomes just an unconditional block statement
> 3. infinite loop as if the condition is always true - until it's false

Grab a dictionary.


More information about the Digitalmars-d mailing list