in reply to Re: Autoloading and anonymous subs
in thread Autoloading and anonymous subs

How do you take the address of a sub that needs to be AUTOLOADed before it is AUTOLOADed? Hmmm?

Be well,
rir

Replies are listed 'Best First'.
Re^3: Autoloading and anonymous subs
by shmem (Chancellor) on Jun 28, 2007 at 21:07 UTC
    *shrug* I just do. It's a magic called autovivification :-P
    You can take a reference to a sub that doesn't exist. It's much like forward declarations of subs:
    package Foo; sub bar; # we'll define that later \&bar; # same effect

    In fact, that's how AutoLoader works - it loads a modules autosplit.ix file which contain forward declarations of subs to be loaded. The CODE slot of the typeglob is allocated, but it's empty. That's why calling such a sub AutoLoader's AUTOLOAD is called, which requires the sub's source file on the fly.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}