18

The second-to-last item on the search() path is (always?) an environment called Autoloads. All I could find about this topic is a sentence on page 26 of the R language definition (pdf).

An Autoloads environment is used for holding proxy objects that may be loaded on demand.

Please can you give me more of an explanation about what this is environment is used for.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
  • 2
    Interesting question. It's mostly answered by reading `?autoload`, and running the example therein. – Josh O'Brien Nov 15 '12 at 17:06
  • 2
    I don't feel knowledgeable enough to give an actual answer but `?Autoloads` and `example(autoload)` provide some decent info on what it is and what it is used for. – Dason Nov 15 '12 at 17:12
  • Josh O'Brien and Dason: Thanks for the tip. I thought I's searched for that, but looking through my history I'd actually looked for `??autolaod`, which doesn't return anything useful. I've drafted an answer based upon the help page; you may want to contribute. – Richie Cotton Nov 16 '12 at 15:54

1 Answers1

12

Autoloading provides a way of loading packages in the future, only at the point at which they are used (if at all). So if a function from a package may soon be used, but (for memory reasons, perhaps) you don't want to load the package unless absolutely necessary, you can use the autoload function to promise to make a function available if it is used.

The Autoloads environment (accessible via as.environment("Autoloads") or .AutoloadEnv) stores the functions that it will promise to load and a character vector, .Autoloaded, that names the packages that need to be loaded.

Further information can be found in the ?autoload help page and R-FAQ 7.6.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
  • 1
    I'm curious if anybody actually uses this thing. – MichaelChirico Apr 27 '16 at 14:02
  • 1
    @MichaelChirico I think that this feature may have been useful in the 1990s when PCs were much less powerful and loading packages took up a non-trivial amount of memory. I don't see much use for this now. – Richie Cotton Apr 28 '16 at 10:04