https://tutorial.ponylang.org/gotchas/divide-by-zero.html
I can elaborate a bit on what is in the tutorial. With the current semantics, you as the application programmer can check for division by zero and throw `error` if you want. Otherwise, every division operation would be partial which given that pony forces you to handle all partial functions, can get to be very painful.
We are working on adding value dependent types and will be revisiting the divide by 0 question. Some work was done on that for a thesis a couple years back but hasn't been integrated into Pony by the author as they have had time constraints since leaving school. You can check out a video about the work here: https://vimeo.com/175746403
It's definitely something that folks bring up. We aren't thrilled with the current functionality but feel its better than the previous functionality and are looking to slow improve the situation over time.
It can definitely bite the uninitiated if they aren't careful.
PS: This is the approach PHP took in the early days too.
For a recent discussion about this on the Isabelle mailing list, see here https://lists.cam.ac.uk/pipermail/cl-isabelle-users/2018-Mar... (search for 1/0)
>>> 0.3 * 3.0
0.8999999999999999
There's are a lot of areas of computer science that touch on these sorts of problems. And people love to do Wat! talks for all those fun edge cases where how computers work and how programming languages work run up against our expectations of what we expect to be correct.
Throwing an error is actually “wrong” as the result should actually be undefined/null but most languages throw for practical reasons.
So in fact it’s most languages that are being “wrong but functional”. Pony is just functioning differently.
If it’s raised and documented well there’s no reason it wouldn’t work as undefined (could throw type errors on usage after that for example).
Well, it can be argued that physics dictates an error is intrinsically better than 0, and that programs care about physics at least as much as about mathematics.