setLoadActions
Set Actions For Package Loading

Description

Specifies hidden functions that are installed with a package, and then run when the package is loaded. Load actions are not intended to be used outside of private package code.

Usage

setLoadAction(action, aname = "", where = topenv(parent.frame()))
setLoadActions(..., .where = topenv(parent.frame()))
getLoadActions(where = topenv(parent.frame()))
hasLoadAction(aname, where = topenv(parent.frame()))
evalqOnLoad(expr, where = topenv(parent.frame()), aname = "")
evalOnLoad(expr, where = topenv(parent.frame()), aname = "")

Arguments

action a "load action": a function of one argument, which is a namespace environment, that is called with the package's namespace when that namespace is loaded.
... load actions. These can be named, as in setLoadActions(First=function(env){}, Second=function(env){}).
expr an expression involving the variable env. This expression is converted to the load action function(env)eval(expr, envir=where) and registered with setLoadAction.
evalOnLoad expects the expression to be wrapped in quote(), or to be the name of a variable containing the expression.
evalqOnLoad expects a literal expression.
where the namespace whose loading triggers the running of load action.
.where the namespace whose loading triggers the running of load action.
aname a character string giving the name for the load action. If omitted, it is a period followed by the new length of the list of load actions.

Details

Load actions are hidden functions in a package that are installed with special names, .__A__<aname> or .__A__.<number>, when the package is installed and run when the package is loaded. They are run after the package's dynamic library (shared object) has been loaded and immediately after the package's .onLoad function is run but before the package's namespace is locked. Hence, they can assign things to the package's namespace. They are called with one argument: the package's namespace environment.
They can do what can be done in the .onLoad function, but give a structured way of adding things to do at load time. Packages used for building other packages, such as Rcpp, can use load actions.
Load actions are not intended to be used outside of private package code.
Value
setLoadAction(action, where)returns a character vector containing the names of the objects in the environment where containing the load actions. The returned names have the prefix ".__A__".
setLoadActions(..., where)returns a character vector containing the names of the objects in environment where containing the load actions. The returned names have the prefix ".__A__".
evalqOnLoad(expr, where)returns a character vector containing the names of the objects in environment where containing the load actions. The returned names have the prefix ".__A__".
evalOnLoad(expr, where)returns a character vector containing the names of the objects in environment where containing the load actions. The returned names have the prefix ".__A__".
getLoadActions(where)returns a named list of all the load actions registered in the environment where. The names will the names used when registering the load action, without the ".__A__" prefix that is added when storing it.
hasLoadAction(aname, where)returns TRUE if the load action has been registered under aname in environment where and FALSE otherwise.
See Also
.onLoad, setHook.
Package methods version 6.0.0-69
Package Index