On Tuesday, 23 January 2024 at 21:40:46 UTC, Renato wrote:

While I can understand your frustration, it seems to me D is not to blame in this instance because the code is quite patently using unsafe constructs (D does not claim to be fully safe).

It pretends to be safe. Consider this:

```
void main() {
    long y = int.max + 1;
    writeln(y);  // -2147483648
    long y2 = int.max;
    writeln(y2 + 1); // 2147483648
    int y3 = y; // Won't compile
}
```

It can only be described as a mess of inconsistency. `int y3 = y;` should be an error and it is. `int.max + 1` silently turning into a negative value is frankly insane because it's the same problem that a few lines below won't compile.

Would something like this work?

```d
double value(T)(T index, double* x) if (is(T : size_t))
```

There's no way to add a template constraint. Many different types, most of which I defined myself, could be sent as an argument.

that it's almost always a mistake to subract from any unsigned type - D scanner correctly warns about that).

It's the inconsistency that's the problem. You have to program as if the compiler doesn't catch anything - sometimes it throws errors, sometimes it lets stuff through because maybe that's what you want. `int y3 = y` in the code above is not necessarily an error.

Reply via email to