Date: Wed, 30 Apr 2025 19:35:11 +0200
To clarify on the second point, you can already express a division by zero
check with a throw on failure using an if statement. The language already
has all the tools to let you do it.
If it was much faster to handle the CPU trap instead, compilers would
likely already detect this pattern and transform the branch into an
unconditional division. The core language already has all the tools, so
this seems more like a quality-of-implementation problem than anything.
A much more interesting proposal would be to change division by zero
globally so that it throws instead of being UB. Maybe this could be a
conditionally supported feature. Maybe it's something that should be
implemented in a compiler first. Maybe it's already implemented somewhere,
not sure.
check with a throw on failure using an if statement. The language already
has all the tools to let you do it.
If it was much faster to handle the CPU trap instead, compilers would
likely already detect this pattern and transform the branch into an
unconditional division. The core language already has all the tools, so
this seems more like a quality-of-implementation problem than anything.
A much more interesting proposal would be to change division by zero
globally so that it throws instead of being UB. Maybe this could be a
conditionally supported feature. Maybe it's something that should be
implemented in a compiler first. Maybe it's already implemented somewhere,
not sure.
Received on 2025-04-30 17:35:24