[Python-Dev] Type/class
Guido van Rossum
guido@digicool.com
Sat, 12 May 2001 16:21:21 -0500
> Also: There are two basic implementation models:
>
> Delegation [a.k.a. "Lifetime sharing", cloning]
> sort of like python -- if you don't know how to handle it "ask"
> a parent object. ( "ask" in quotes, because I've recently been
> in a long argument about whether objective-C & smalltalk can
> really be said to "send messages" , or if it's "just" dynamic
> lookup and function application! )
>
> Extension [a.k.a. "Birth sharing", copying, concatenation ]
> more like how I imaging C++ vtables are built -- the python
> equivalent would be like merging all of the class __dict__'s
> together with name-clase priority going to the nearest
> relative.
>
> ( "Life Sharing" vs. "Birth Sharing" -- is a change in the
> base class after object creation inherited by the object? )
Interesting. So is the rest of this thread, but since Python is not a
prototype language and is unlikely to become one, I'd like to mention
that Python 2.2 will likely allow you to choose either paradigm, on a
per-class basis, using metaclasses.
I'm finding metaclasses in Python useful for different things than
they are in Smalltalk, and I expect that they will continue to play a
less important role. But they are important because they control many
"policy" aspects of Python classes/types: e.g. whether instances have
a __dict__ or a specific set of slots (maybe even typed slots),
whether changes can be made to a class after it's been created, the
semantics of multiple inheritance, and so on.
Right now, my metaclasses continue to be implemented in C, although I
expect that eventually they will be subclassable in Python. Watch the
descr-branch in the CS tree. I hope I'll soon have some time to write
a PEP, too.
It's an interesting journey! The book I am reading about this:
"Putting Metaclasses to Work" by Ira Forman and Scott Danforth.
http://cseng.awl.com/book/0,3828,0201433052,00.html
--Guido van Rossum (home page: http://www.python.org/~guido/)