# Python3k extended grammar

Tue May 23 10:51:03 EDT 2000

```Thomas Malik <340083143317-0001 at t-online.de> wrote:
: ...
:> Oh, and 1/2 might give you
:> a float.
:>
:> Rather minor changes. Then of course..
:>
: Uff, hard hammer that, rather. How do you do integer division, then ? And

I rather like pascal approach with div: 5 div 2 = 2
: what is it good for, anyway ? I mean, what's the advantage of it for
: breaking many exisiting programs ?

hmmm... clearer syntax, less confusing arithmetics?
I agree that the sheer number of existing application outweights these

: I'm surely not against improvements in the Python language, but
: 1. case insensitivity sounds like complete nonsense to me. Who needs it,
: actually ?

my words :-)

: 2. promoting integer divisions to float sounds quite stupid to me:
: (x/y) * y + x % y == x should always hold true in any sane language

should it?
or rather:
(x div y) * y + x % y

I am parsing the first expression as:
take x, divide by y, multiply by y, (that's x again), add x modulo .. oops,
what is the definition of % for real numbers.. oops, what if x and y are
integers... ok, I finally got it!

whereas I parse the second expression as:
take x, do integer division (ok, so x and y have to be integers), multiply by y
(remainder remains) etc etc...

oh, it introduces another keyword... a disaster

/ should not be used for integer division. I consider this a design flaw
(FORTRAN or C suffer from this too, but there it is acceptable, since these
languages were _not_ written to be easily readable).
It should either promote operands to float, or to newly introduced rational
type. Floats have their problems. Rational numbers have their problems.
But float division is useful in physics. Rational division
is useful if you want to have the result as exact as possible, e.g. in
mathematics or logic. Integer division is unnatural, integer numbers are
ring, not field.

If you do some intensive computation in a loop using float division, you end
up with rounding errors.
If you use rational divisions, you face the danger of _really big_
nominators and denumerators, with unexpected overflows, unless you make them
long integers and loose performance...
Which is better default? Hard to decide.... But certainly not integer
division.

: about the optional(!) static typing, good idea. But no new interpunctuation

why not, when it is justified? after all, complex numbers were not in python
from the beginning....

: One reason why i've never learned Perl is that basically every character on
: my keyboard is being used for some builtin variable or one of n ways to
: write down an attribute access. We don't need that in Python.

I fully agree.
Like using / to denote two _completely_ different things: integer division
and float division

Sorry for flaming, I got carried away :-)

--
-----------------------------------------------------------