----- Original Message ----- From: "Guido van Rossum" firstname.lastname@example.org To: "David Abrahams" email@example.com Cc: firstname.lastname@example.org; email@example.com Sent: Saturday, March 30, 2002 8:47 AM Subject: Re: [Python-Dev] PEP 285: Adding a bool type
6) Should we eventually remove the inheritance relationship between Int and Bool?
I hope so. Bool is-a Int doesn't seem like the right relationship to me, unless perhaps we make Int is-a Long... naah, not even then.
Hm. In your favorite language bool is one of the integral types. Doesn't that imply pretty much the same thing?
Well, I try not to play favorites <0.002 wink>, but the implicit conversion rules in C++ are admittedly and unfortunately liberal. However, bool is detectably NOT derived from int in C++:
void f(int const&); f(false); // error! assert(boost::is_base_and_derived<int,bool>::value); // fails!
Anyway, do you have a use case where it matters?
Given that Bool is immutable, I have no cases other than examples of type introspection which can be written to account for the fact that Bool is-a Int. However, it does make certain things trickier to get right:
numeric_types = [ Int, Long, Bool, Float, Complex ] for t in numeric_types: if isinstance(x, t): # Do something...
This sort of thing could depend on getting the order of the list right (I didn't).