Is there any real reason to use "const"?
Dennis
dkorpel at gmail.com
Mon Jan 24 18:13:12 UTC 2022
On Monday, 24 January 2022 at 17:55:39 UTC, H. S. Teoh wrote:
> For some reason I was under the impression that D didn't allow
> unbraced loop bodies because in the case of loops such errors
> could be a lot worse than in if-statements.
D doesn't allow a single `;` loop body to prevent this mistake:
```D
for (int i=0; i<l; i++);
```
You have to write {} for an empty body.
It also doesn't allow dangling else, and function bodies need
braces {}. Other than that, I don't recall D demanding {}.
More information about the Digitalmars-d
mailing list