EVOLUTION-MANAGER
Edit File: strict_list.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: Strict lists</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 strict_list {xfun}"><tr><td>strict_list {xfun}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Strict lists</h2> <h3>Description</h3> <p>A strict list is essentially a normal <code><a href="../../base/html/list.html">list</a>()</code> but it does not allow partial matching with <code>$</code>. </p> <h3>Usage</h3> <pre> strict_list(...) as_strict_list(x) ## S3 method for class 'xfun_strict_list' x$name ## S3 method for class 'xfun_strict_list' print(x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Objects (list elements), possibly named. Ignored in the <code>print()</code> method.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>For <code>as_strict_list()</code>, the object to be coerced to a strict list. </p> <p>For <code>print()</code>, a strict list.</p> </td></tr> <tr valign="top"><td><code>name</code></td> <td> <p>The name (a character string) of the list element.</p> </td></tr> </table> <h3>Details</h3> <p>To me, partial matching is often more annoying and surprising than convenient. It can lead to bugs that are very hard to discover, and I have been bitten by it many times. When I write <code>x$name</code>, I always mean precisely <code>name</code>. You should use a modern code editor to autocomplete the <code>name</code> if it is too long to type, instead of using partial names. </p> <h3>Value</h3> <p>Both <code>strict_list()</code> and <code>as_strict_list()</code> return a list with the class <code>xfun_strict_list</code>. Whereas <code>as_strict_list()</code> attempts to coerce its argument <code>x</code> to a list if necessary, <code>strict_list()</code> just wraps its argument <code>...</code> in a list, i.e., it will add another list level regardless if <code>...</code> already is of type list. </p> <h3>Examples</h3> <pre> library(xfun) (z = strict_list(aaa = "I am aaa", b = 1:5)) z$a # NULL! z$aaa # I am aaa z$b z$c = "create a new element" z2 = unclass(z) # a normal list z2$a # partial matching z3 = as_strict_list(z2) # a strict list again z3$a # NULL again! </pre> <hr /><div style="text-align: center;">[Package <em>xfun</em> version 0.16 <a href="00Index.html">Index</a>]</div> </body></html>