OT Re: [Python-Dev] PEP 285: Adding a bool type

Gary Stephenson garys at ihug.com.au
Sun Mar 31 19:05:34 EST 2002


> One obvious difficulty with this suggestion is that it requires even
> more careful class hierarchy design: if two classes A and B are both
> formed from constraining the same superclass, then the intersection of A
> and B should also be a class.

Indeed! Without wishing to overstate my own limited understanding of the
issues involved here, I believe that such a type system would need to be
entirely consistent from a set-theoretical pespective.  Which would imply (I
think) that all subclasses must in fact define mutually exclusive subsets of
their parent, and (obviously) that an object having any particular
most-specific-type (MST) implicitly precludes it from also conforming to any
heirs of that type.  This in turn raises the thorny spectre that in order to
define a subclass (subtype) one first needs full knowledge of all other
extant subtypes!

Of course, other difficulties also lurk.  Each object  needs to retain
knowledge of both it's declared type and it's current most-specific-type, so
that an object of current MST "square", but of declared type "Rectangle"
would allow itself to somehow be mutated back to a MST of "Rectangle"
(dubbed by Date and Darwen as "Generalisation by Constraint"), but if it's
declared type was "square" it would not be so allowed.   Etc, etc, ...

<snip>

> I haven't read those manifestos, though, so maybe they have some way of
> addressing this difficulty.  Anyway, this is getting a little far afield
> from bools and ints...

So?  This is the Python list - it's OK to go OT, isn't it?  Just so long as
it's interesting - at least to somebody!  ;-)

cheers,

gary





More information about the Python-list mailing list