Make foreach element optional

Per Nordlöw per.nordlow at gmail.com
Tue Mar 16 12:49:13 UTC 2021


I find myself writing

foreach (_; 0 .. n)
     doSomething(); // no using the variable `_`

.

What about relaxing the syntax to allow

     foreach (; 0 .. n)

and/or

     foreach (0 .. n)

?

Thereby making the `ForeachTypeList` of `AggregateForeach` in the 
grammar rule [1] optional.

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


More information about the Digitalmars-d-learn mailing list