Arafel,
You're certainly correct. Priorities change. It used to be
thought that backwards compatibility was the way to attract
developers. But today the keyword is "safety".
Apparently 2022 was the year of the C++ successor. Some features
of D were mentioned in the discussion but D as a candidate was
not. Maybe it's time to re-visit the priorities.
Anyways, my post was simply to highlight the issue.
On Thursday, 8 February 2024 at 15:26:16 UTC, kdevel wrote:
Elegant and correct is this version:
```d
import std.stdio;
int main()
{
char[] something = ['a', 'b', 'c'];
writeln("len: ", something.length);
writeln("typeid(something.length): ",
typeid(something.length));
writeln ("i: -1");
foreach (i, _; something)
writeln("i: ", i);
return 0;
}
```
But it is still a bit too "clever" in the `foreach` statement
due to the unused variable `_`.
It has a bigger problem. What happens when I change the code in
the loop but forget to change the code outside the loop? This is
why people complain about Python's lack of a do/while loop. So
no, not elegant.
Additionally, it doesn't address the issue. It still requires me
to both realize the issue with comparing an int to length's
mystery type, as well as to fix it for the compiler.
(And it's beside the fact that the start value could just as
easily be an int (parameter for example) that could take a
negative value. This was the case for one of my cases.)