opts_function {constructive} | R Documentation |
Constructive options for functions
Description
These options will be used on functions, i.e. objects of type "closure", "special" and "builtin".
Usage
opts_function(
constructor = c("function", "as.function", "new_function"),
...,
environment = TRUE,
srcref = FALSE,
trim = NULL
)
Arguments
constructor |
String. Name of the function used to construct the object, see Details section. |
... |
Additional options used by user defined constructors through the |
environment |
Boolean. Whether to reconstruct the function's environment. |
srcref |
Boolean. Whether to attempt to reconstruct the function's srcref. |
trim |
|
Details
Depending on constructor
, we construct the object as follows:
-
"function"
(default): Build the object using a standardfunction() {}
definition. This won't set the environment by default, unlessenvironment
is set toTRUE
. If a srcref is available, if this srcref matches the function's definition, and iftrim
is leftNULL
, the code is returned from using the srcref, so comments will be shown in the output ofconstruct()
. In the rare case where the ast body of the function contains non syntactic nodes this constructor cannot be used and falls back to the"as.function"
constructor. -
"as.function"
: Build the object using aas.function()
call. back todata.frame()
. -
"new_function"
: Build the object using arlang::new_function()
call.
Value
An object of class <constructive_options/constructive_options_function>