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

David Eppstein eppstein at ics.uci.edu
Sun Mar 31 18:27:47 EST 2002


In article <a87uvb$dst$1 at lust.ihug.co.nz>,
 "Gary Stephenson" <garys at ihug.com.au> wrote:

> Date and Darwen discuss this issue extensively in their 3rd Manifesto tome
> [1],   and they opine that a "real" OO type system should automatically
> promote a "square rectangle" to an actual square instance (assuming of
> course, that a "square" class has been defined as an heir of rectangle with
> the appropriate constraint). They call this feature "Specialisation by
> Constraint".
> 
> Personally, whilst I find their arguments most interesting and persuasive,
> it would appear to my neophyte eye that actually implementing such a system
> might prove even more problematic than trying to trying to satisfy all
> twelve of Codd's rules at once! (which in turn has proven to be marginally
> more difficult than lifting yourself up by your own bootlaces <g>).

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.

E.g., suppose you're interested in polygons as a general superclass,
and you use them in two standard computational geometry algorithms: a 
line arrangement construction algorithm that needs to know about 
trapezoids (four-sided polygons with two sides horizontal) and a 
Delaunay triangulation algorithm that needs to know about inscribed 
polygons (all vertices are on a single circle).  Then, if your automatic 
specialization system sees a polygon with four sides, two of which are 
horizontal, and all four vertices are on a circle, it needs to invent a 
new "inscribed trapezoid" class to describe such a shape, even though 
probably none of your algorithms care about inscribed trapezoids.

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...

-- 
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