From ripley at stats.ox.ac.uk  Mon Oct 23 09:22:10 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 23 Oct 2006 08:22:10 +0100 (BST)
Subject: [Rd] Getting hold of a package's environment from C code
In-Reply-To: <m28xj71wqa.fsf@ziti.fhcrc.org>
References: <eb555e660610221256g3952a408sc25f06afe8307cb5@mail.gmail.com>
	<453BD456.4050702@stats.uwo.ca>
	<eb555e660610221424kac664fanba7b998b12faaf1e@mail.gmail.com>
	<m2ac3n3ce9.fsf@ziti.fhcrc.org> <m28xj71wqa.fsf@ziti.fhcrc.org>
Message-ID: <Pine.LNX.4.64.0610230810330.10964@gannet.stats.ox.ac.uk>

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.)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




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