update_formals: Update the formals of a function

Description Usage Arguments Details Value

View source: R/update_formals.R

Description

Update the formals of a function

Usage

1
update_formals(.fun, ..., .list = FALSE)

Arguments

.fun

The targeted function whose formals should be updated. Warning: If the function belongs to the same environment, then the update will be permanent, whereas a local copy (with adjusted formals) will be created otherwise.

...

The arguments to be used when updating the formals of .fun.

.list

A logical value, default FALSE. This can be used when the stuff that you want to update with already is contained in a list or an environment. NOTE: Only the first argument given to ... will in this case be recorded!

Details

The dotsMethods, i.e. ..., allows inheritance of arguments from a parent function to its children. But if several children require different arguments passed to them, some minor problems can occur (unless all of the children have ... as an argument in order to work as a sink for superfluous arguments). This function attempts to avoid those problems (for functions without dotsMethods by comparing the formals of the targeted child-function with the content captured in the dotsMethods, whereupon it updates any common components and ignores the part of ... that has no relevance.

Value

The result of this function is that the formals of .fun is updated in the calling environment. If the targeted function is defined outside of this environment, a local copy will be created. This might trigger some "bad" behaviour, and it might be safer to use a construction based on crate_call instead.


LAJordanger/leanRcoding documentation built on Feb. 27, 2020, 4:42 p.m.