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

Dennis Ritchie via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 24 14:09:22 PST 2016


On Thursday, 24 November 2016 at 22:04:00 UTC, LiNbO3 wrote:
> As you can see [1] the `while (true)` is lowered into `for 
> (;true;)` so it's all about what construct pleases you the most.
>
> [1] 
> https://github.com/dlang/dmd/blob/cd451ceae40d04f7371e46df1c955fd914f3085f/src/statementsem.d#L357

OK, thanks.

The next question is:
What principles guided when choosing between `for (;;) { ... }` 
and `while (true) { ... }` ?

For example, there are two options:
https://github.com/dlang/phobos/blob/master/std/algorithm/sorting.d


More information about the Digitalmars-d mailing list