On 2007-10-02, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Oct 2, 12:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> On 2007-10-01, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> > Scheme has prefix numeric operators, so that 1/2 is >> > unambiguously (for the interpreter and the user) a litteral for >> > 'the fraction 1/2'. You can't avoid the confusion in python, as >> > binary operators are infix. Of course, we could create a new >> > kind of litteral. Let's see, / and // are already operators, >> > so why not use /// ? ;) >> >> But you wouldn't actually need a literal rational represention. > > In which case rationals are better off in a module than in the > language!
I was supposing that 1/2 would result in a rational number, which would require language support, whether it's a literal rational number or a division of two integer constants. >> But I'm just playing Devil's Advocate here; I like rationals >> in Scheme and Lisp, but I don't see a need for them in Python. > >> On the other hand, Python has had complex numbers a long time, >> and it doesn't need those more than rationals, does it? My >> guess is that it got complex numbers but not rationals because >> rationals just aren't very efficient. > > Another guess could be that real numbers being closed under the > four arithmetic operations, there is no danger to accidentally > step into complex numbers. OTOH floats and rationals are two > (conflicting) ways of extending integers. You would have to adopt a few simple conversion rules, a la Scheme. Inexact numbers are contagious, for example. It was pretty shocking for a Scheme programmer to see the gmpy package break that rule. ;) > I use rationals a lot, and I don't want them in the language :) Fair enough. -- Neil Cerutti The pastor will preach his farewell message, after which the choir will sing, "Break Forth Into Joy." --Church Bulletin Blooper -- http://mail.python.org/mailman/listinfo/python-list