On Dec 15, 11:47 am, Robert Kern <robert.k...@gmail.com> wrote: > On 12/14/11 12:32 PM, Steven D'Aprano wrote: > > > On Wed, 14 Dec 2011 10:56:02 +0200, Jussi Piitulainen wrote: > >> I'm not misunderstanding any argument. There was no argument. There was > >> a blanket pronouncement that _in mathematics_ mod is not a binary > >> operator. I should learn to challenge such pronouncements and ask what > >> the problem is. Maybe next time. > > > So this was *one* person making that claim? > > > I understand that, in general, mathematicians don't have much need for a > > remainder function in the same way programmers do -- modulo arithmetic is > > far more important. But there's a world of difference between saying "In > > mathematics, extracting the remainder is not important enough to be given > > a special symbol and treated as an operator" and saying "remainder is not > > a binary operator". The first is reasonable; the second is not. > > The professional mathematicians that I know personally don't say that > "remainder > is not a binary operator". They *do* say that "modulo is not an operator" in > mathematics just because they have reserved that word and the corresponding > notation to define the congruence relations. So for example, the following two > statements are equivalent: > > 42 = 2 mod 5 > 2 = 42 mod 5 > > The "mod 5" notation modifies the entire equation (or perhaps the = sign if > you > like to think about it like that), not the term it is immediately next to. > Python's % operator is a binary operator that binds to a particular term, not > the whole equation. The following two are not equivalent statements: > > 42 == 2 % 5 > 2 == 42 % 5 > > It's mostly kvetching on their part that programming language designers > misunderstood the notation and applied the name to something that is > confusingly > almost, but not quite, the same thing. They aren't saying that you couldn't > *define* such an operator; they would just prefer that we didn't abuse the > name. > But really, it's their fault for using notation that looks like an operator. > > -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless enigma > that is made terrible by our own mad attempt to interpret it as though it > had > an underlying truth." > -- Umberto Eco
Thanks Robert, I think you cut right through the confusion there. To tie it back in with python language design; all the more reason not to opt for pseudo-backwards compatibility. If python wants a remainder function, call it 'remainder'. Not 'rem', not 'mod', and certainly not '%'. Its the more pythonic way; a self-describing name, rather than poorly defined or poorly understood cryptology. -- http://mail.python.org/mailman/listinfo/python-list