4 ms·
It’s not wrong. It’s just a definition issue. The result is undefined in mathematics. Throwing an error is actually “wrong” as the result should actually be un
by abritinthebay 8y ago
It’s not wrong. It’s just a definition issue. The result is undefined in mathematics.
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.
- pron 8y agoYou are right, but the question is what most programmers want. It is certainly reasonable to believe that most want some special treatment of division by zero. Assuming the program is connected to some actuator (even a screen) -- as most programs are -- while not wrong mathematically, this results in something that is wrong "physically," and doing so silently, without a mechanism to later recover, from the result alone, whether division by zero occurred.
- abritinthebay 8y agoRight, though there’s nothing intrinsically better about throwing an error - it’s just the idiom programmers are more familiar with. 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).
- pron 8y ago> Right, though there’s nothing intrinsically better about throwing an error - it’s just the idiom programmers are more familiar with. 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.