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

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 25 03:10:44 PST 2016


On 25.11.2016 11:33, Claude wrote:
> ...
>
> Between "for(;;)", "while(true)" and "do while(true)", I would use the
> "while (true) { }" for pure readability and semantic reasons.
> ...

What semantic reasons?

> I reckon "for(;;)" form is used for debug reasons (so you can easily
> insert conditions to transform an infinite loop into a finite one).

You can just as easily edit the while condition. I use it because 
"unconditional loop" is less silly than "loop until true is false".


More information about the Digitalmars-d mailing list