On 5/10/2011 3:41 AM, Gregory Ewing wrote:
Actually, you're right. What I've presented is a paper-and-pencil implementation of the Python data model. Together with a set of rules for manipulating the diagram under the direction of Python code, you have a complete implementation of Python that you can execute in your head.
I think that it would be both fun and useful to have an animated graphical tutorial that used and box and arrow model. Names should be in ovals (instead of the little boxes used here due to text limitations) to differentiate them from objects. Immutable objects could have solid boundaries and mutables a broken line boundary. Collection objects would have dotted lines to separate slots. Ovals could also use different lines for builtins, globals, and locals.
And you NEED such an implementation in order to reason correctly about Python programs under all circumstances. I find it very difficult to imagine *any* implementation of Python, computer-based or otherwise, that doesn't have something equivalent to references. Whether you call them that, or pointers, or arrows, or object bindings, or something else, the concept needs to be there in some form.
Since namespaces link names in a namespace with objects not in the namespace, any practical implementation needs a third entity to link or associated each name with an object. This is pretty much needed to explain multiple links without objects being in multiple locations. It is also needed to explain how an object can link to itself.
-- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list