under_construction: Function to construct/revise functions

Description Usage Arguments Details Value

View source: R/under_construction.R

Description

Use under_construction to simplify the task of creating and updating your code. Warning: To get the full advantage of this function, the logic argument clean_workspace should be changed from its default value FALSE to TRUE.

Usage

1
2
under_construction(.uc_fun, .uc_package_name = NULL, ...,
  high_details_level = FALSE, clean_workspace = FALSE, script_files = "")

Arguments

.uc_fun

The function that we want to construct.

.uc_package_name

The name of a package, that must be available on the search-path. Use this argument if .uc_fun is a part of a package, and the code need access to functions imported from other packages or to the internal objects of the package. The default value NULL will assume that there's no need for such additional information.

...

Arguments to be used by targeted function .fun. Note that update_formals is used in order to feed the arguments to .fun, and it's thus possible to add extra objects here if you want to protect them from annihilation when clean_workspace is set to true.

high_details_level

Logic argument with default value FALSE, in which case only the names of the objects in the captured function environment will be presented. If high_details_level is set to TRUE, then ls.str will be used instead to give more details about the captured objects.

clean_workspace

Logic argument that should be set to TRUE, but whose default value nevertheless is FALSE (since some users might become a tad bit enervated if their precious workspace suddenly is wiped clean without any warning). When set to TRUE, the only objects in your workspace that will survive is those specified by .fun and the dotsMethods, i.e. ....

script_files

Use this if you need to run some scripts in order to get .uc_fun to work properly. Default value "", in which case nothing is done. Note that this feature can increase the computational time quite a bit if the scripts are large. If the scripts are mostly static, i.e. that they are not updated with new stuff while working with you targeted function, then it might be a better idea to source them (when needed ) outside of this function.

Details

The idea of this function is to ease the construction and maintenance of your code, but it must be used in tandem with capture_env to reach this goal. The code capture_env() should be included in the targeted function, in order to create a (cloned) copy of that functions environment in the workspace (the global environment). The contribution of under_construction is to add the arguments of the targeted function (only when necessary). It will also take care of attach and detach on the above mentioned environment, and it will list the content of the environment. In addition, if the logic argument codeclean_workspace is set to its recommended value TRUE, then the workspace will be cleansed for superfluous stuff at every running.

Value

When used in tandem with capture_env, this function will list and attach the objects that function captured. If clean_workspace is set to TRUE, there will also be a cleansing of the workspace. If there's no capture_env() inside the body of the targeted function, then the function will run as if called directly, and if it does not fail any results from it will be returned via under_construction.


LAJordanger/UnderConstruction documentation built on May 3, 2019, 5 p.m.