quo {nseval} | R Documentation |
quo
captures its argument literally, that is, without evaluating,
and constructs a quotation. A quotation has two parts: an
expression expr(q)
with an environment env(q)
. (Like in
writing, an 'expression' may simply be a set of words, but a
'quotation' comes bundled with a citation, to reference a context
in which it was said.)
quo_(expr, env)
is the normally evaluating version. It
constructs a quotation given an expression and environment.
as.quo(x)
converts an object into a quotation. Closures,
formulas, and single-element dots can be converted this way.
quo(expr, env = arg_env_(quote(expr), environment()), force = FALSE) quo_(expr, env, force = FALSE) env(q) ## S3 method for class 'quotation' env(q) env(q) <- value ## S3 replacement method for class 'quotation' env(q) <- value expr(q) ## S3 method for class 'quotation' expr(q) expr(q) <- value ## S3 replacement method for class 'quotation' expr(q) <- value is.quotation(x) as.quo(x) ## S3 method for class 'function' as.quo(x) ## S3 method for class 'quotation' as.quo(x) ## S3 method for class 'dots' as.quo(x) ## S3 method for class 'formula' as.quo(x) ## S3 method for class 'lazy' as.quo(x) ## Default S3 method: as.quo(x)
expr |
An expression. For |
env |
An environment. |
force |
Immediately evaluate the expression and create a forced quotation, i.e. one that stores an expression and value, but no environment. |
q |
A quotation object. |
value |
An updated value. |
x |
Any object. |
A quo is parallel to a 'promise' which is the data structure R uses to hold lazily evaluated arguments. A quo is different from a promise because it is an immutable data object.
As a data object, a quo does not automatically evaluate like a promise, but can be evaluated explicitly with the methods value or force_. A quo is immutable, so it does not mutate into a "forced" state if you choose to evaluate it.
A function can capture its arguments as quotations using arg
.
A dots object is a list of quotations.
quo_
and quo
return an object of class "quotation".
as.quo
returns a quotation.