On Saturday, 11 December 2021 at 20:22:13 UTC, frame wrote:
```d
// iteration works, but scope behind does nothing
for({int i=0; j=0;} i<10; ++i, {++i; ++j;} ){}

// endless loop
for({int i=0; j=0;} i<10; {++i; ++j;} ){}
```

Not sure if bug or feature but it is inconsistent for me and thus a reason to avoid it.

That's because `{++i; ++j;}` in an expression context is shorthand syntax for `delegate void () {++i; ++j;}`.

If you look at the [grammar for the `for` statement][1], you'll see that the "initialize" part allows a *statement*, but the "test" and "increment" parts only allow *expressions*.

[1]: https://dlang.org/spec/statement.html#ForStatement

Reply via email to