On Sat, 14 Jan 2006 18:18:12 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote:
>In the discussion of equality, the issue that decimal('3.0') == 3.0 is >False came up as a reason for changing the behavior of ==. The problem >with this is that the proposed change doesn't really fix anything, it >just gives different wrong behavior. The correct fix would seem to be >fixing python's handling of numbers. > >It's not clear from the PEP why test for equality always fails. While >the PEP says that interactions with floats are disallowed as "to >tricky", comparisons seem to be an exception. In particular, equality >comparisons seem to always return false, whereas checking for >magnitude seems to work. > >What appears to be missing in Python is a coherent model for all >numberic types. Other languages have this, so there's no obvious >reason that Python can't. Or maybe Python does, and I've overlooked >it. In that case, pointers to documentation would be appreciated. >If it doesn't exist, then I think this is something that should be >addressed for Py3K. > >I'd like to work on that. The idea would be that all the numeric types >are representations of reals with different properties that make them >appropriate for different uses. The goal would be a model for a >numeric type that captures those properties in a way that allows them >to be combined to give sane behavior without being "to tricky". > >To get started on that, I want to consider how other languages with >rich numeric type systems model them. I'm going to look at a couple of >languages in the LISP family. I'd like to solicit the community for >the names of languages (and pointers to references, if possible!) with >a coherent view of a rich set of numeric types. > I suppose you have already found scheme's rsr5 spec, e.g., http://www.schemers.org/Documents/Standards/R5RS/ while thinking about numbers, the issue of equivalence that got us here is also explored in scheme http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_sec_6.1 and the section that follows in on numbers http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_sec_6.2 for common lisP http://www.lispworks.com/documentation/HyperSpec/Front/index.htm you can also chase lots of interesting links (some dead though) from http://www.cetus-links.org/oo_clos.html cltl2 is at http://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html Now try to get some work done ;-) BTW, IIRC Ada's numbers include some interesting provisions for representing numbers in fixed point with specified fractional accuracy I google and found http://www.adaic.org/standards/95lrm/html/RM-0-1.html browsing a bit, scalar types are at http://www.adaic.org/standards/95lrm/html/RM-3-5.html integers include unsigned by way of genera modular definition http://www.adaic.org/standards/95lrm/html/RM-3-5-4.html and here is the fixed point http://www.adaic.org/standards/95lrm/html/RM-3-5-9.html Whoo, I haven't been into that stuff almost since Ada was "green" ;-) Makes me wonder if generators could usefully have rendezvous('?, es?) ;-) Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list