[pypy-dev] Restricted language

Rocco Moretti roccomoretti at netscape.net
Tue Jan 21 04:39:04 CET 2003

Armin Rigo <arigo at tunes.org> wrote:

< excellent discussion of confusion between (host) Python and (interpreted) Python snipped >
>Here we are using Python's __getitem__ protocol to implement Python's
>__getitem__ protocol.  I see nothing wrong in that, but it is easy to get
>confused.  To make things clearer I would way:
>    self.valuestack.push(w.getitem(v))
>Think about
>the type() function; it could not return the real type of the implementing
>object, because you couldn't implement lists or ints with a custom class.  And
>it cannot call a new method __type__() of the object, because you cannot add
>such a new method to all already-existing built-in objects.  You could hack
>something that calls __type__() if it exists and returns the real type
>otherwise, but you are running into trouble when interpreting programs that
>define __type__() methods for their own purpose.  This is the kind of
>confusion we are bound to run into if we are not careful.

So if I understand you correctly, we should not use (either explicitly or implicitly) any of the special methods of the objects we create for the interpreter. The only acceptable use is member dereferencing (object.attribute).

Only host objects are allowed to be part of special method use. (e.g. in function calls, in expressions such as a+b, etc.)
This is not strictly a technical limitation in most cases, but good practice so that we avoid confusion between the two levels.

Is this an accurate interpretation?


P.S. In your implementation of EPython exceptions, how would associated traceback objects be handled?

The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

More information about the Pypy-dev mailing list