News for hackers. Stuff that matters.
Re:Python, unlike C, has the mod operator always return a po... by staticassertion on Wednesday December 29, 2021 @06:33PM (#29731530)
I think this is a bit different. Pony's div is total, and in order to be total div by 0 is 0, which is not a particularly absurd idea.

That said, I do feel that Pony should have added a 'panic' concept and then forced actors to handle panics, but that's me.

Re:Python, unlike C, has the mod operator always return a po... by kibwen on Wednesday December 29, 2021 @11:44PM (#29733698)
> which is not a particularly absurd idea

It's not completely untenable, but it's still kinda janky. I've never heard of any mathematical argument that justifies division by zero yielding 0; contrast 0^0, which at least has an argument for yielding 1: http://mathscitech.org/articles/zero-to-zero-power

Re:Python, unlike C, has the mod operator always return a po... by noswi on Thursday December 30, 2021 @06:31AM (#29735866)
From programming perspective, there's nothing sufficiently preposterous in the idea of dividing by zero that would require bringing the whole world to a low-level halt just for attempting that by default. You tried to calculate the average value of what turned out to be an empty list? Go suffer the most severe exception, like the ones reserved for those reading from nonexistant memory.
Re:Python, unlike C, has the mod operator always return a po... by Asraelite on Thursday December 30, 2021 @07:50AM (#29736287)
Another common case is adjusting some value according to a spatial vector's magnitude, like normalizing a vector or scaling gravitational attraction according to the distance between two points.

In the majority of these cases the most reasonable answer is 0.

Re:Python, unlike C, has the mod operator always return a po... by duskwuff on Thursday December 30, 2021 @04:31AM (#29735134)
> I've never heard of any mathematical argument that justifies division by zero yielding 0

0/x = 0 for all x except zero; defining 0/0=0 removes that exception.

Re:Python, unlike C, has the mod operator always return a po... by AlbinNP on Thursday December 30, 2021 @05:27AM (#29735489)
x/x = 1 for all x except 0; defining 0/0 = 1 removes that exception.
Re:Python, unlike C, has the mod operator always return a po... by hwayne on Thursday December 30, 2021 @11:42AM (#29738206)
Split the difference, 0/0 = 0.5
Re:Python, unlike C, has the mod operator always return a po... by ben_w on Monday January 03, 2022 @04:38AM (#29778956)
It gets worse: differentiation would be 0/0 if you went straight to the limit rather than just approaching it, so 0/0 can be any differentiable function, not just a value.

(Caveat: I’m probably being slightly imprecise with my language here)

Re:Python, unlike C, has the mod operator always return a po... by staticassertion on Thursday December 30, 2021 @10:21PM (#29744511)
I think it's worth all getting on the same page on the fact that math is fake and stupid. If it's more useful for 0/0 to == 0, that's justification enough imo.
Re:Python, unlike C, has the mod operator always return a po... by remexre on Thursday December 30, 2021 @02:07AM (#29734429)
Re:Python, unlike C, has the mod operator always return a po... by dataangel on Thursday December 30, 2021 @11:24AM (#29738019)
Maybe the best argument is that the average of zero items should be zero?
Re:Python, unlike C, has the mod operator always return a po... by housecarpenter on Thursday December 30, 2021 @03:52PM (#29741294)
But then why should the average of zero items be zero? It still seems like just an arbitrary choice to me.