Hi

Am 2025-03-20 17:00, schrieb Gina P. Banyard:
And again, ValueErrors are only ever added when it *easy* to check if the condition is satisfied, and it very clearly points to a programming error.

I still find it baffling that telling someone that the code they wrote, even if it is decades old, is incorrect is somehow bad. Because the alternative is letting users have bugs in their software that they can ignore.

I agree with that (and Kamil, who said the same thing). Passing an undocumented value that does *something* is a clear programmer error that would also break when adding new values, which is generally considered a backwards compatible change. Pointing out this error as an actual error before it causes a silent behavioral change is a good thing.

The `round()` function would be a good example. PHP 8.4 both added a validation of the `$mode` parameter if an integer value is given and also added new rounding modes (just as an enum in the gold release, though). Before PHP 8.4 it was possible to use `round($value, 5)` by accident and it would be interpreted as `PHP_ROUND_HALF_UP`. Now if we would've added a new `const PHP_ROUND_WHATEVER = 5;` constant this code would silently have changed its behavior. As a user I certainly would be interested in finding out about this mistake. A clear ValueError is easy to fix in a backwards compatible way, but incorrectly rounded values can remain undetected for so long that it becomes impossible to fix them, since the stored data might already be poisoned, including all backups.

Best regards
Tim Düsterhus

Reply via email to