the "Right Thing" [was: PEP0238 lament]

Steven D. Majewski sdm7g at Virginia.EDU
Mon Jul 23 23:35:28 CEST 2001


  1/2 = 0
  1/2 = 0.5 

It's been asserted that one of those expressions above is "illogical" . 
( Actually, it's been asserted that both of them are illogical, but
  each has been asserted by a different group of people. ) 


Which one seems to depend on your initial point of view: 

1: The "close to the hardware" POV knows that computer CPU's have
 separate integer and floating point units, integer and floating 
 point are disjoint sets, and hiding that fact is only going to
 confuse folks and delay the time the confront that truth. 

2: The "abstract" POV, which is best implemented in Lisp & Scheme 
  where number classes are nested sets:

 { fixnums (native ints) } 

 { integers } == { fixnums } + { bignums } 

 { rational } == { integers } + { ratios } 

  so from that POV, it's not to be viewed as the "illogical" 
    int op int => float 
  but as:
    rational op rational => rational. 

 However, Lisp also has another orthogonal classification which is
 disjoint: exact and inexact, which does map into hardware representation, 
 as well as representing irrationals and algorithms that yield numeric
 approximations. 

  So again, it's not viewed as: 
     SQRT(int) => float
  but: 
     SQRT(number) => number (may be inexact) 
     

[ I'm not sure I know how to weigh the question of backward compatability,
  effeciency, and all of the other issues involved here for Python and come
  up with  a better answer on what's the "Right thing" , but I don't think
  you can win this argument with what seems to be "logical" ! ] 

-- Steve Majewski






More information about the Python-list mailing list