PEP 285: Adding a bool type
David Eppstein
eppstein at ics.uci.edu
Tue Apr 2 18:23:41 EST 2002
In article <pTpq8.53356$S52.1844974 at news2.tin.it>,
Alex Martelli <aleax at aleax.it> wrote:
> > yes. but a real bool could be introduced as module for now (for the RPC
> > and marshalling people that need one) i think its not needed otherwise
>
> A standard library module sounds good. Or maybe it could go into operator.
So you'd be happy with a Boolean class, as long as it isn't convertable
to integers and none of the standard operators are changed to return it?
That doesn't seem very nice either from the aesthetic purity-of-design
point of view (non-convertable is more pure than convertable maybe but
it's impure to have a Boolean type but return int from a comparison) nor
from the code-documentation point of view (have to put explicit Boolean
conversions on results of comparisons if you want to properly express
the fact that your function's return value should be interpreted as a
truth value not an integer) nor from the pragmatic point of view
(Booleans would be too cumbersome to use except in unusual situations).
In comparison the actual PEP is similarly not-pure but gives better
expressivity and possibly adds minor functionality (ability to make code
that behaves differently for ints and for bools, just like now you can
behave differently for lists and for tuples even though they are
interconvertable).
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list