On Tue, Mar 16, 2010 at 2:32 PM, Steven D'Aprano <st...@pearwood.info> wrote:
> But mixed arithmetic runs into the problem, what do you want the result
> type to be? Given (say) decimal+float, returning either a Decimal or a
> float will be the wrong thing to do some of the time, so better to
> prohibit mixed arithmetic and let folks handle their own conversions.
> So +1 on continuing to prohibit mixed arithmetic.

I'm not disagreeing, but I really wonder, what is the value of
supporting mixed comparisons then? Just because you *can* assign a
meaning to it doesn't mean you should.

OTOH I'm sure a lot of people would like to see mixed arithmetic
supported, the PEP be damned, and they would probably be happy with
any simple rule about the return type even if it's not always ideal. I
note that there are cases where converting a long to a float also is
the wrong thing to do, and yet mixed long/float operations always
return floats. If you are amenable to this argument, I would propose
to make the result of mixed operations return a Decimal, since in some
"intuitive complexity" sense an int is a simpler type than a float and
a float is a simpler type than a Decimal -- so results return the more
complex type. But my intuition on this isn't super strong and I could
live with always returning a float as well -- there are always casts
to force the issue.

-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to