Inspect an argument
arg_inspect() provides argument introspection in the context of
lazy evaluation. Compared to
returned information is more complete and takes R's lazy evaluation
semantics into account: if an argument is passed around without
arg_inspect() is able to return the expression
at the original call site as well as the relevant scoping
environment in which this expression is supposed to be evaluated
when the argument is forced. To accomplish this,
climbs the call stack to find where an argument was first supplied,
with which expression, in which evaluation environment.
arg_inspect_() is the standard-evaluation version of
arg_inspect() and takes a symbol and a call stack object.
arg_inspect(x)arg_inspect_(expr, stack, only_dots = FALSE)
- An argument to a function.
- A quoted symbol giving the name of the argument to inspect.
call_stackobject as returned by
- Whether to stop introspection once
forwarded dots have been climbed. Setting this to
TRUEis only useful for inspecting dots (cf.
tidy_dots()which does not follow symbols).
arg_inspect() should be used with two caveats in mind. First,
it is slower than
lazyeval::lazy(). Thus you should probably avoid using it in
functions that might be used in tight loops (such as a loop over
the rows of data frame). Second,
arg_inspect() ignores all
reassignment of arguments. It has no way of detecting that an
inspected argument got reassigned along the way, and will continue
to climb the calls looking for an earlier call site. These two
limitations are inherent to the stack climbing approach that powers
A list containing: