From thomas@biostat.washington.edu  Wed Oct 29 20:56:15 1997
From: thomas@biostat.washington.edu (Thomas Lumley)
Date: Wed, 29 Oct 1997 12:56:15 -0800 (PST)
Subject: R-alpha: Using autoload and smaller 'base' package
In-Reply-To: <97Oct29.151248est.26572@mailgate.bank-banque-canada.ca>
Message-ID: <Pine.SUN.3.95.971029123224.7756A-100000@troi>

On Wed, 29 Oct 1997, Paul Gilbert wrote:

> If I understand this correctly, the whole package gets autoloaded the
> first time any function in the package is referenced (and then never
> unloaded until q()?).

Yes, though you can explicitly unload a package with
	detach("package:package") 
and it will still be reloaded automatically when needed. 
 
> Would it be possible/logical/easy  to make autoload work on a function
> by function basis? (Sounds a bit like an S .Data directory.) Is there a
> limit on how many packages can be autoloaded?
> 

Possible and easy, but not logical:

There's no strict limit to the number of packages, but the overhead goes
up sharply as the packages get smaller.  For the current sorts of package
the overhead would be trivial, but for one-function packages it would be
quite large.  Increasing the number of packages loaded also slows a lot of
things down, as the search path gets longer and longer. 

There is also some overhead on opening files, so loading lots of little
packages is slower than loading one big package.

I think autoload() is only worthwhile on largish, coherent blocks,
especially in its current interpreted form. Anything more ambitious would
probably require delving into the internal C code that finds and evaluates
things, and considering horrible things like caching and buffering for
disk access. 

	-thomas


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


R-alpha: Using autoload and smaller 'base' package
Thomas Lumley