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

Dan Sugalski dan@sidhe.org
Tue, 29 Oct 2002 14:19:29 -0500


At 2:11 PM -0500 10/29/02, Guido van Rossum wrote:
>  >  > I think (2) could be resolved using "ghosts" -- this is what Zope's
>>   > persistency mechanism uses.  The names must be present, but their
>>   > content is loaded on demand.  I expect that (1) probably could also be
>>   > solved this way.
>>
>>  That assumes that you can "preload" all of the names at
>>  initialization, correct?  IOW, that you know the contents of the
>>  namespace in advance.  Not a huge limitation, but not the same as
>>  lazy ghost-creation on lookup.
>
>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)

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)
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk