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

LiNbO3 via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 24 14:04:00 PST 2016


On Thursday, 24 November 2016 at 21:57:15 UTC, Dennis Ritchie 
wrote:
> Hi all,
>
> In the source code, written in D, is often used in the design 
> of the `for (;;) { ... }`
>
> Maybe someone has specific examples of translation of code in 
> asm, where `while (true) { ... }` or `for (;;) { ... }` affect 
> the performance or cross-platform programs.
> It would be interesting to see samples.

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


More information about the Digitalmars-d mailing list