[Types-sig] Proposal: "abstract" type checking

Paul Prescod paulp@ActiveState.com
Sat, 17 Mar 2001 18:18:40 -0800


Robin Thomas wrote:
> 
> ...

> This works very, very well. I don't have to change any of my existing code, 
> unless some of my Python code really demands that an object be of a certain 
> concrete type. (I haven't found this case in real life yet,and if I did, 
> the worst that could happen is that Python would generate a traceback, 
> which is just fine and better than what happens with the previous 
> alternatives.

I find it somewhat uncomfortable to have objects masquerading as other
objects. For one thing it means that you must implement each and every
method implemented by the built-in types to be "safe". For another thing
it may break existing code. Also, if I have a sequence, can I decide
whether to emulate both list AND tuple? Can I also emulate a file if I
happen to have file-like methods?

I think we should move forward to a world where abstract
protocols/interfaces/... are explicit (as they are in the C-world)
rather than trying to pretend that ListType and TupleType *are* abstract
types. I think it confuses things further.

-- 
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.activestate.com/pythoncookbook