[Types-sig] Type/class unification

Vladimir Marangozov Vladimir.Marangozov@inrialpes.fr
Thu, 26 Nov 1998 19:07:20 +0100 (NFT)


I take advantage of the silence caused by the massive US turkey feast
to drop a line regarding the type/class unification vs. the interface
discussion.

It seems to me that if the "clype" remake is MOPish enough, many people
would feel more comfortable w.r.t. what they think a Python interface
should look like. By definition, a MOP is like the statue of Liberty --
it says that we should feel free to do whatever we like ;-)

A MOPish clype redesign should give us means to inspect or reshape every
piece of code as a surgeon, so if someone wants to ask at some point
whether an instance or a class conforms to some protocol/interface, all
that has to be done is:

- decide what is labeled as an interface / protocol / class
- use the MOP to build a function, based on the previous decision, that
  will answer the question

It's quite unclear to me, even after the 50 types-sig messages that landed
in my inbox, what an (optional) Python interface is, and why should I feel
happier if the Scarecrow (or another) formula is implemented in some way,
given the actual implementation of Python's classes.  Obviously, there's
some need out there that I don't really understand and there are limitations
in Python that prevent solving the problem easily.

Anyway, I wonder whether if we have another implementation of classes and
more tools to hammer on them (i.e inspect & modify their structure & behavior)
the interface/static typing issues wouldn't become clearer (or better yet,
irrelevant :-) ...

An aside: An interesting pointer appeared in c.l.py about a language
called Ruby which has some nice properties. IMHO it worths a look at the
implementation. (Here's a comment from a file "object.c" that bootstraps
the Ruby Universe:

    /*
     * Ruby's Class Hierarchy Chart
     *
     *                           +------------------+
     *                           |                  |
     *             Object---->(Object)              |
     *              ^  ^        ^  ^                |
     *              |  |        |  |                |
     *              |  |  +-----+  +---------+      |
     *              |  |  |                  |      |
     *              |  +-----------+         |      |
     *              |     |        |         |      |
     *       +------+     |     Module--->(Module)  |
     *       |            |        ^         ^      |
     *  OtherClass-->(OtherClass)  |         |      |
     *                             |         |      |
     *                           Class---->(Class)  |
     *                             ^                |
     *                             |                |
     *                             +----------------+
     *
     *   + All metaclasses are instances of the class `Class'.
     */

This reminds me of a diagram Guido posted on the obsolete egroups list,
which contains another kind of animals (turtles). I'm appending Guido's
message for the sake of the comparison, hoping that some of us would
discuss the class/type unification. In my eyes, the practical solution of
this problem is quite important and it may well influence the interface
discussion.

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov@inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252