Do Loop with Variable

Dukc ajieskola at gmail.com
Thu Jul 17 13:43:33 UTC 2025


On Tuesday, 8 July 2025 at 16:40:24 UTC, Quirin Schroll wrote:
> I have the feeling this isn’t gonna fly, but I’ll say it 
> anyways because maybe someone finds a solution.
> ```d
> do (int x = 0)
> { }
> while (++x < 10);
> ```
> which would be equivalent to
> ```d
> {
>     int x = 0;
>     do
>     { }
>     while (++x < 10);
> }
> ```

I would probably prefer if symbols declared inside the do 
statement would be accessible in the condition. Would be a 
breaking change though, requiring a warning from the compiler if 
a symbol declared both inside and outside the do block would be 
used in `while` and probably doing it over an edition switch.


More information about the dip.ideas mailing list