develooper Front page | perl.perl5.porters | Postings from September 2002

Re: [RFC] jit.pm - load modules and subroutines just in time

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
September 29, 2002 04:05
Subject:
Re: [RFC] jit.pm - load modules and subroutines just in time
Message ID:
4.2.0.58.20020929125611.03ee1ef0@mickey.dijkmat.nl
At 11:52 AM 9/29/02 +0200, Rafael Garcia-Suarez wrote:
>Michael G Schwern wrote:
> > On Sun, Sep 29, 2002 at 12:33:25AM +0200, Elizabeth Mattijsen wrote:
> > > So the typical use inside a module is to have:
> > >
> > >  package Your::Module;
> > >  use jit;
> > >
> > > in the source.  And to place all subroutines that you want to be 
> loadable on
> > > demand after the (first) __END__.
> >
> > I have a Clever Idea!  The "put things after the __END__ block" hack has
> > always bothered me about AutoLoader style things.  It would be interesting
> > if one could write their code normally and just put "use jit" at the 
> top and
> > it worked.  jit.pm would really be a source filter.  The filter would 
> simply
> > blow away all the code below "use jit" and install an AUTOLOAD 
> routine.  The
> > AUTOLOAD would then read from $INC{'Your/Module.pm'} rather than *DATA.
>I like this idea ! and you can even use "no jit;" to disable this feature
>for some chunks of code.

Hmmm.... If you really want to go the source filter way, I'd rather see it 
implemented as an attribute to a subroutine:

   sub name : jit { }

or something like that.  That would give you the best granularity...


>I just don't like the name of the module. This is not a pragma, it's not
>lexically scoped.

It wouldn't be the only one...  ;-)   And actually, it is scoped to an 
extent in that you can have multiple C<use jit> in an application:

   use jit 'now';
   use module1; # all subroutines loaded, including modules used in module1
   use jit 'ondemand';
   use module2; # no subroutines loaded, including modules used in module2


>Other names : Jit ? Filter::AutoLoad ? Acme::Defer ?

I think this is a basic functionality in Perl that warrants being a pragma.


Liz


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About