>>>>> "JNP" == Joshua N Pritikin <[EMAIL PROTECTED]> writes:

  JNP> On Thu, Feb 03, 2000 at 02:38:27PM -0500, [EMAIL PROTECTED] wrote:
  >> in Event.pm have stub subs like this which only load the real one and
  >> overload the sub's typeglob.
  >> 
  >> sub Event::io {
  >> 
  >> require 'Event/io.pm' ;
  >> 
  >> *Event::io = \&Event::io::new ;
  >> 
  >> goto &Event::io ;
  >> }
  >> 
  >> how crazy/workable is that?

  JNP> The idea is to avoid adding to the optree.  io.pm isn't very long to
  JNP> begin with so doing something like this is just going to erode an
  JNP> already dubious savings of memory.

  JNP> Graham, feel free to correct me.  :-)

i thought the issue was load time, not code size. the idea was not to
load code until you need it to save on startup time. cgi.pm does many
tricks with this. my idea fixes the problem i had which was caling a
nonexistant method in Event.pm and getting a false AUTOLOAD failure. by
having these short stubs you have no need for AUTOLOAD (which is slow)
and this code is short and direct. it just requires the source code,
aliases it's new sub to the io sub and goes to that sub (which is
overloaded on the actual event::io sub). so this gets called and
executed only the first time and thereafter the real event::io::new sub
is called.

uri

-- 
Uri Guttman  ---------  [EMAIL PROTECTED]  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com

Reply via email to