20.4 Quosures
quosures are a data structure from rlang
containing both and expression and an environment
Quoting + closure because it quotes the expression and encloses the environment.
Three ways to create them:
- Used mostly for learning:
new_quosure()
, creates a quosure from its components.
With a quosure, we can use eval_tidy()
directly.
And get its components
Or set them
- Used in the real world:
enquo()
oenquos()
, to capture user supplied expressions. They take the environment from where they’re created.
- Almost never used:
quo()
andquos()
, to match toexpr()
andexprs()
.