[Python-Dev] Type/class

Steven D. Majewski sdm7g@Virginia.EDU
Fri, 11 May 2001 09:43:32 -0400 (EDT)


Catching up on this thread -- mostly because it looks like I'm
going to have to use ExtensionClass to make pyobjc classes into
python classes rather than types -- you can add that to the 
lisp of real world uses of Don's  Metaclass hack that Tim  
questioned. 

 Reading up on MetaClasses in Smalltalk again makes me appreciate
the simplicity of a prototype system where everything is just
an object -- all objects can be cloned, and some objects are 
only used for cloning -- they are the exemplars of their type
which fill the role of Classes. 

 Unfortunately, although prototypes would be a lot simpler, it 
would be a pretty incompatible change for Python -- I can't think
of any way to get there without a lot of breakage. 

 (Still -- I wonder if there's a way they could be used under
the covers in the implementation to make it simpler. Prototype
semantics are basically a superset of Class based semantics, which
is how it was easy to do Smalltalk in Self.)

 Classes are necessary for statically typed O-O languages, but 
IMHO, make a lot less sense for dynamic languages. If Py3K were
to be a clean start, I'ld urge basing it on prototypes, but as
an incremental creation -- I don't know how to get there from 
here (unless it could sneak in under the implementation covers!)


 BTW: XlispStat, which has a prototype object system with multiple
inheritence also doesn't have "super" -- there is a 
(call-next-method [ args... ]) function/macro which searches for
 the base classes. I'm sure there's a lower level function to 
 just get the next method, but typically, call-next-method is
 what's used. There is no search for non-method attributes, as
 all of the base class instance vars are merged and made into
 slots of the instance itself. ( There's no class variables -- 
 there's no classes.) 

 The closest python equivalent would be, as has been discussed
in this thread, a  super method or function that does attribute
 lookup on the bases. 


-- Steve Majewski