Note that there are some explanatory texts on larger screens.

plurals
  1. PONamespaces without packages
    primarykey
    data
    text
    <p>In reorganising my code base I’d like to clean up my code sharing mechanism. So far I’m using <code>source</code> for lots of small, largely self-contained modules of functionality.</p> <p>However, this approach suffers from a number of problems, among them</p> <ul> <li>the lack of tests for circularity (accidental circular <code>source</code> chains),</li> <li>complex syntax required to properly specify include paths (<code>chdir=TRUE</code> argument, hard-coded paths),</li> <li>potential of name clashes (when redefining objects).</li> </ul> <p>Ideally I’d like to get something alike to the Python module mechanism. The R package mechanism would be overkill here: <strong>I do <em>not</em> want to generate nested path hierarchies, multiple files with tons of metadata and manually build the package</strong> just to get a small, self-contained, reusable code module.</p> <p>For now I’m using a code snippet which allows me to solve the first two problems mentioned above. The syntax for inclusion is like this:</p> <pre><code>import(functional) import(io) import(strings) </code></pre> <p>… and a module is defined as a simple source file which resides in the local path. <a href="https://gist.github.com/klmr/5301304" rel="noreferrer">The definition of <code>import</code> is straightforward</a> but I cannot solve the third point: I want to import the module into a separate namespace but from what I see the namespace lookup mechanism is pretty hard-wired to packages. True, I could override <code>`::`</code> or <code>getExportedValue</code> and maybe <code>asNamespace</code> and <code>isNamespace</code> but that feels very dirty and has the potential of breaking other packages.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload