[Python-Dev] Type/class

Samuele Pedroni Samuele Pedroni <pedroni@inf.ethz.ch>
Fri, 11 May 2001 16:56:48 +0200 (MET DST)


Hi.

> 
>  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. 
> 
I agree, I often read that Smalltalk is "simple" up to metaclasses,
on the other hand the casual user can just ignore them.

>  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.)
> 
[Ignoring the fact that code and changes require coders]

Thinking in terms of proto-objects, parent slots and list parent slots:

python instance I have data slots and a parent slot __class__,

python classe G have data slots and a list parent slot __bases__,

then we have the python rules (not very uniforms):
function from I directly => function
function from I.__class__ => bound method
function from C => unbound method

That's the difficult part for every model that aims to remain compatible.

Samuele Pedroni.