On 03.10.23 20:26, Paul Backus wrote:
Naturally, this lowering is completely absent from [the language spec's section on `foreach`.][1] According to the spec, the only ways to iterate over a `struct` type are `opApply` and the input range interface.

I think it would probably be less confusing to have both `opApply` and `empty`/`front`/`popFront` take precedence over this lowering, but I have no idea how much existing code would be broken by such a change. At the very least, though, this needs to be documented.

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

For some further reading, there's an open issue about the unexpected slicing: https://issues.dlang.org/show_bug.cgi?id=14619

Reply via email to