[Rd] Getting hold of a package's environment from C code

Luke Tierney luke at stat.uiowa.edu
Mon Oct 23 15:18:32 CEST 2006


On Mon, 23 Oct 2006, Prof Brian Ripley wrote:

> On Sun, 22 Oct 2006, Seth Falcon wrote:
>
>> Seth Falcon <sfalcon at fhcrc.org> writes:
>>> Perhaps:
>>>
>>> R_FindNamespace(mkString(where))
>>
>> Sorry, this won't help you for package-level code as this function is
>> part of the internal use only API.  It would be nice to have access to
>> it or a similar function from C in package code.
>
> Hmm, it is declared in Rinternals.h, which is the public header for
> manipulating R objects at C level.  As such it is available to packages,
> but as it is not documented in 'Writing R Extensions' it is subject to
> change.
>
> R_FindNamespace is essentially the same code as Duncan M provided, so it
> is a pretty simple function.  (It still contains a test that namespaces
> are supported, and that seems long overdue for removal.)

Except for a small detail: the code in R_FindNamespace protects the
expression before callign eval -- this is needed since eval does not.

Best,

luke

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:      luke at stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu




More information about the R-devel mailing list