Operator symbol for "nb_intdivide"
Guido van Rossum
guido at python.org
Thu Jul 26 17:54:50 EDT 2001
Peter Dobcsanyi <petrus at pobox.com> writes:
> But, I don't like the "//" operator symbol what we are supposed to use
> for implementing "a // b == floor(a/b)". Here are my reasons, in not any
> particular order reflecting (my subjectively assigned) importance:
>
> - It is ugly, two characters.
Lots of operators are two characters (**, <<, ==).
> - Some languages use it for starting comments.
So? Some languages use a semicolon as a comment. Does that mean we
can't use it as a statement separator?
> - "//" is hard to read, i.e. quickly clearly distinguish from "/"
> the other division operator.
I don't believe this. If you can't distinguish / from //, you need
new glasses. :-)
> - When the transition period over (around 3.x or something) the
> visual and typing characteristic of "//" can be source of error.
*Any* choice of symbol can be a source of error.
> At some stage in the future, the warnings will be turned off, everybody
> knows the new rules. But typing mistakes, oversights happen, so I can
> accidentally write "/" instead of "//" and vice versa:
>
> def foo(x,y):
> # stuff here
> ...
> z = x / y
> ..
> # blah blah
> ..
>
> i_wanted_int_div_but_mistyped_then_did_not_notice_for_a_while = foo
>
> And there is no warning any more.
*Usually* this will be clear very quickly because at some point the
expected resulting integer will be fed into an operation that requires
integers, e.g. list[i] or i<<n.
> I would like to suggest to use a clearly distinguishable one-character
> symbol for the "nb_intdivide". PEP238 is to fix a "design fault". If we
> go for it despite of all the _temporary_ pain, we should not be shy,
> there is nothing wrong with doing it radically not just semantically but
> also visually. One of the nice virtue of the Python language is that it
> is readable, keep it this way.
>
> "nb_intdivide" and "nb_divide" are very different let's show this
> difference. Among the still free symbols ("?", "@", "$" I guess) I
> would suggest to use "$" for the integer division.
>
> Running_for_cover_ly y'rs,
You had me there for a moment... :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-list
mailing list