rk.replace.function {rkward}R Documentation

Replace a function inside its package environment / namespace

Description

rk.replace.function can be used to replace a function inside a different package / namespace. It is mainly intended for internal usage inside rkward, e.g. to replace menu and select.list with appropriate GUI implementations.

Usage

rk.replace.function(functionname, environment, replacement,
  copy.formals = TRUE)

Arguments

functionname

name of the function to be replaced (character).

environment

package environment or namespace, where replacment should be done.

replacement

the replacement. This should be a function.

copy.formals

logical; whether to copy the formals from the original function.

Details

The original function is assigned to the environment rkward::.rk.backups with the same name as the original, and can be referred to from the replacement. WARNING: This mechanism does not support several subsequent replacments of the same function, nor does it support replacement of generics.

WARNING: This function can be used to alter - and disrupt - internal functions in arbitrary ways. You better know what you are doing.

WARNING: Does not work well on generics!

Value

Returns NULL, invisibly, unconditionally.

Author(s)

Thomas Friedrichsmeier rkward-devel@kde.org

See Also

assignInNamespace, debug

Examples


## Not run
rk.replace.function ("history", as.environment ("package:utils"),
  function () {
    cat ("This is what you typed:\n")
    eval (body (.rk.backups$history))
  })
## End not run


[Package rkward version 0.6.5 Index]