RL: reload a function in a package from its source folder

View source: R/RL.R

RLR Documentation

reload a function in a package from its source folder

Description

Not for final package distribution: this is a kludge to avoid having to rebuild the whole package just to propagate a change in a single function.

Usage

RL(f, path = NULL, package = NULL)

Arguments

f

unquoted name of function

path:

path to source file containing new definition for f; Default is to run find starting at the user's home directory, looking for a file called paste0(substitute(f), ".R")

package:

name of package to which f belongs. Defaults to the first package returned by getAnywhere(f)

Details

Here's what RL(f) does:

  • the file path is sourced into an empty environment E

  • for each symbol S in E:

    • if S is a function, set its binding environment to namespace:PACKAGE

    • unlock the binding for S in namespace:PACKAGE

    • bind S to E$S in namespace:PACKAGE

    • lock the binding for S in namespace:PACKAGE

    • if S is bound in package:PACKAGE:

      • unlock the binding for S in package:PACKAGE

      • bind S to E$S in package:PACKAGE

      • lock the binding for S in package:PACKAGE

where PACKAGE stands for the value of package.

Author(s)

John Brzustowski jbrzusto@REMOVE_THIS_PART_fastmail.fm


MotusWTS/motusServer documentation built on Aug. 8, 2024, 10:23 p.m.