EVOLUTION-MANAGER
Edit File: quosure-tools.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Quosure getters, setters and predicates</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for quosure-tools {rlang}"><tr><td>quosure-tools {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Quosure getters, setters and predicates</h2> <h3>Description</h3> <p>These tools inspect and modify <a href="topic-quosure.html">quosures</a>, a type of <a href="topic-defuse.html">defused expression</a> that includes a reference to the context where it was created. A quosure is guaranteed to evaluate in its original environment and can refer to local objects safely. </p> <ul> <li><p> You can access the quosure components with <code>quo_get_expr()</code> and <code>quo_get_env()</code>. </p> </li> <li><p> The <code>quo_</code> prefixed predicates test the expression of a quosure, <code>quo_is_missing()</code>, <code>quo_is_symbol()</code>, etc. </p> </li></ul> <p>All <code>quo_</code> prefixed functions expect a quosure and will fail if supplied another type of object. Make sure the input is a quosure with <code><a href="new_quosure.html">is_quosure()</a></code>. </p> <h3>Usage</h3> <pre> quo_is_missing(quo) quo_is_symbol(quo, name = NULL) quo_is_call(quo, name = NULL, n = NULL, ns = NULL) quo_is_symbolic(quo) quo_is_null(quo) quo_get_expr(quo) quo_get_env(quo) quo_set_expr(quo, expr) quo_set_env(quo, env) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>quo</code></td> <td> <p>A quosure to test.</p> </td></tr> <tr valign="top"><td><code>name</code></td> <td> <p>The name of the symbol or function call. If <code>NULL</code> the name is not tested.</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>An optional number of arguments that the call should match.</p> </td></tr> <tr valign="top"><td><code>ns</code></td> <td> <p>The namespace of the call. If <code>NULL</code>, the namespace doesn't participate in the pattern-matching. If an empty string <code>""</code> and <code>x</code> is a namespaced call, <code>is_call()</code> returns <code>FALSE</code>. If any other string, <code>is_call()</code> checks that <code>x</code> is namespaced within <code>ns</code>. </p> <p>Can be a character vector of namespaces, in which case the call has to match at least one of them, otherwise <code>is_call()</code> returns <code>FALSE</code>.</p> </td></tr> <tr valign="top"><td><code>expr</code></td> <td> <p>A new expression for the quosure.</p> </td></tr> <tr valign="top"><td><code>env</code></td> <td> <p>A new environment for the quosure.</p> </td></tr> </table> <h3>Empty quosures and missing arguments</h3> <p>When missing arguments are captured as quosures, either through <code><a href="enquo.html">enquo()</a></code> or <code><a href="defusing-advanced.html">quos()</a></code>, they are returned as an empty quosure. These quosures contain the <a href="missing_arg.html">missing argument</a> and typically have the <a href="empty_env.html">empty environment</a> as enclosure. </p> <p>Use <code>quo_is_missing()</code> to test for a missing argument defused with <code><a href="enquo.html">enquo()</a></code>. </p> <h3>See Also</h3> <ul> <li> <p><code><a href="defusing-advanced.html">quo()</a></code> for creating quosures by <a href="topic-defuse.html">argument defusal</a>. </p> </li> <li> <p><code><a href="new_quosure.html">new_quosure()</a></code> and <code><a href="new_quosure.html">as_quosure()</a></code> for assembling quosures from components. </p> </li> <li> <p><a href="topic-quosure.html">What are quosures and when are they needed?</a> for an overview. </p> </li></ul> <h3>Examples</h3> <pre> quo <- quo(my_quosure) quo # Access and set the components of a quosure: quo_get_expr(quo) quo_get_env(quo) quo <- quo_set_expr(quo, quote(baz)) quo <- quo_set_env(quo, empty_env()) quo # Test wether an object is a quosure: is_quosure(quo) # If it is a quosure, you can use the specialised type predicates # to check what is inside it: quo_is_symbol(quo) quo_is_call(quo) quo_is_null(quo) # quo_is_missing() checks for a special kind of quosure, the one # that contains the missing argument: quo() quo_is_missing(quo()) fn <- function(arg) enquo(arg) fn() quo_is_missing(fn()) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>