Dan Sugalski wrote:
> At 02:04 PM 2/1/2001 -0500, Ken Fox wrote:
> >Isn't the trick to detect the necessary modules at compile time?
> 
> Nope, no trick at all. The parser will have a list of functions--if it sees
> function X, it loads in module Y. (Possibly version Z) Nothing fancy needs
> to be done.

Hmm. I was hoping that Perl 6 would be a bit smarter about this than
Perl 5. Is the following code going to work the same as Perl 5?

  sub getpwnam {
     print "OK\n";
  }

  getpwnam();

If it does then I can understand doing it in the parser. If it calls
the user-defined sub though then I think it will have to be done after
symbol resolution (and Perl doesn't require forward declaration, so this
means waiting until the entire program source has been seen).

Anyways, it's not something that can be done now with Perl 5 -- which
is what I meant by "the trick".

> The list of functions that trigger this automagic use-ing of modules should
> be reasonably small.

Seems to be some debate over how big the list should be. Does it include
time()? ;)

Something else to consider is whether auto-loading can occur in response
to something other than an unbound symbol (or a symbol "on the list" if
we use your implementation). Can we auto-load "bigint" if we see
10_000_000_000? Auto-load different optimizers or garbage collectors
if we see lots of closures? Auto-load the Perl parser if we see string
eval?

It'd be really powerful if auto-load were tied to pattern matching on
the parse tree. That code could implement auto-load, macros and lots of
other language features.

- Ken

Reply via email to