Add nice summary by Marcin 'Qrczak' Kowalczyk from c.l.py for and

against unifying ints and rats.
This commit is contained in:
Guido van Rossum 2001-08-08 15:36:41 +00:00
parent 71818368c7
commit f162a1d29c
1 changed files with 31 additions and 0 deletions

View File

@ -71,6 +71,37 @@ Open Issues
- Should shift and mask operators be allowed for rational numbers?
For rational numbers with integer values?
- Marcin 'Qrczak' Kowalczyk summarized the arguments for and
against unifying ints with rationals nicely on c.l.py:
Arguments for unifying ints with rationals:
- Since 2 == 2/1 and maybe str(2/1) == '2', it reduces surprises
where objects seem equal but behave differently.
- / can be freely used for integer division when I *know* that
there is no remainder (if I am wrong and there is a remainder,
there will probably be some exception later).
Arguments against:
- When I use the result of / as a sequence index, it's usually
an error which should not be hidden by making the program
working for some data, since it will break for other data.
- (this assumes that after unification int and rational would be
different types:) Types should rarely depend on values. It's
easier to reason when the type of a variable is known: I know
how I can use it. I can determine that something is an int and
expect that other objects used in this place will be ints too.
- (this assumes the same type for them:) Int is a good type in
itself, not to be mixed with rationals. The fact that
something is an integer should be expressible as a statement
about its type. Many operations require ints and don't accept
rationals. It's natural to think about them as about different
types.
References