|
|
|
|
|
by Tainnor
2179 days ago
|
|
I don't think that the average of an empty list being zero is semantically correct, but I can accept that it may not be so bad in practice (e.g. if it shows up like that in a UI and you display the number of elements anyway). But I still think in other situations I'd want to be yelled at for trying to divide by zero. E.g. imagine I'm trying to compute the slope of a secant between two points. If both points are the same, I'd like the compiler to yell at me (the problem either makes no sense here, indicating a problem somewhere else in my code, or that I should instead compute the derivative) - in most cases, 0 would be the wrong answer. I think the issue here is that with division by zero you lose continuity (unless you use +Inf) which can contradict intuition. I'm not saying it doesn't work for Pony, maybe it does, but I don't think I would feel comfortable with that behaviour. Silent wrapping around on overflow is arguably even worse, that I could definitely see leading to logic errors. |
|