[Python-Dev] Patch to use dict subclasses in eval(), exec

Guido van Rossum guido@python.org
Tue, 29 Oct 2002 14:26:26 -0500


> >Correct.  I don't see this as a huge limitation -- all "autoload"
> >features that I'm familiar with (Emacs, Tcl; how about Perl?) require
> >you to know at least the auto-loaded names in advance.  (Also in my
> >defence you only mentioned the cost of unpickling everything as an
> >argument. :-)
> 
> Perl doesn't require it. If a method call is made but that method 
> name doesn't appear in the object's inheritance hierarchy, perl walks 
> up the tree looking for a method named AUTOLOAD and if it finds one 
> calls that. The AUTOLOAD method then has the opportunity to do 
> something--satisfy the call, dispatch to a parent class, or pitch a 
> fit. It's valid for an AUTOLOAD method to satisfy the request without 
> instantiating a method for it. (In which case the next invocation of 
> that method will end up back in AUTOLOAD)

Um, as long we're doing *method* lookup, Python's __getattr__ can do
all that.

> Works for subroutines too, though the hierarchy isn't supposed to be 
> walked for those. (Older versions of perl would do it, but that's 
> been deprecated)

OK, so if there's a global AUTOLOAD and no global x, looking for x
will call AUTOLOAD to satisfy x, right?  Python doesn't do this, and
this is what the "hookable namespace" feature is aiming at.

--Guido van Rossum (home page: http://www.python.org/~guido/)