On Thu, May 7, 2020 at 10:33 AM Oscar Benjamin <oscar.j.benja...@gmail.com> wrote: > > I've come to the seemingly obvious conclusion that if there is *any* > difference between x and y then it's always better to say that x != y. >
And having worked in languages where floats and integers are fundamentally different beasts, I disagree: it is extremely practical (even if not pure) to have them compare equal. SourcePawn (the language generally used for modding games like Counter-Strike) is strongly-typed and does not allow floats and ints to be used interchangeably - except that you can do arithmetic and they'll be type-folded. So if you have a function TakeDamage that expects a floating-point amount of damage, and another function GetHealth that returns the player's health as an integer, you have to add 0.0 to the integer before it can be used as a float. Actual line of code from one of my mods: SDKHooks_TakeDamage(client, inflictor, attacker, GetClientHealth(client) + 0.0, 0, weapon); Every language has to choose where it lands on the spectrum of "weak typing" (everything can be converted implicitly) to "strong typing" (explicit conversions only), and quite frankly, both extremes are generally unusable. Python tends toward the stricter side, but with an idea of "type" that is at times abstract (eg "iterable" which can cover a wide variety of concrete types); and one of those very important flexibilities is that numbers that represent the same value can be used broadly interchangeably. This is a very good thing. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/HASE7PZIQO4FLDPLT5ZGDKVRJDWIKJXR/ Code of Conduct: http://python.org/psf/codeofconduct/