We recommend using eval_tidy()
in your DSLs as much as possible
to ensure some consistency across packages (.data
and .env
pronouns, etc). However, some DSLs might need a different
evaluation environment. In this case, you can call eval_tidy_()
with the bottom and the top of your custom overscope (see
as_overscope()
for more information).
eval_tidy_(expr, bottom, top = NULL, env = caller_env())
An expression.
This is the environment (or the bottom of a set of
environments) containing definitions for overscoped symbols. The
bottom environment typically contains pronouns (like .data
)
while its direct parents contain the overscoping bindings. The
last one of these parents is the top
.
The top environment of the overscope. During tidy evaluation, this environment is chained and rechained to lexical enclosures of self-evaluating formulas (or quosures). This is the mechanism that ensures hygienic scoping: the bindings in the overscope have precedence, but the bindings in the dynamic environment where the tidy quotes were created in the first place are in scope as well.
The lexical environment in which to evaluate expr
.
Note that eval_tidy_()
always installs a .env
pronoun in the
bottom environment of your dynamic scope. This pronoun provides a
shortcut to the original lexical enclosure (typically, the dynamic
environment of a captured argument, see enquo()
). It also
cleans up the overscope after evaluation. See overscope_eval_next()
for evaluating several quosures in the same overscope.