From ripley at stats.ox.ac.uk  Wed Feb  8 20:08:04 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 8 Feb 2006 19:08:04 +0000 (GMT)
Subject: [Rd] How to change names when importing with a NAMESPACE (was:
 NAMESPACE Q: does import as exist?)
In-Reply-To: <m23bitdbjm.fsf_-_@ziti.local>
References: <D79013E40FEF254AAF0D72DFC94F274816B00B@extas4-hba.tas.csiro.au>
	<m2mzh2edjq.fsf@ziti.local> <43E9DFBC.4090704@stats.uwo.ca>
	<m2lkwldgl8.fsf@ziti.local> <m23bitdbjm.fsf_-_@ziti.local>
Message-ID: <Pine.LNX.4.64.0602081904310.28253@gannet.stats.ox.ac.uk>

This is indeed described in

http://www.stat.uiowa.edu/~luke/R/namespaces/morenames.html

linked from developer.r-project.org.

with the comment

   The purpose of baz is to import some of the exports of foo and bar and
   re-export them, using renaming in one case: bar's export g is imported
   under the internal name hh, and the internal variable hh is exported
   under the name gg. [Renaming seems like a useful option, but it may
   turn out to create too many complications and need to be dropped.]

It's been there since 1.7.0 and not yet been dropped.  (I would also 
suggest checking the R-News article on namespaces, which I have not done.
But checking the developer site is always worthwhile.)

It would be nice to have more end-user documentation on namespaces, and I 
have suggested it in the past.  A project for you, perhaps?


On Wed, 8 Feb 2006, Seth Falcon wrote:

> Well, it seems that the following does what I want.  In the NAMESPACE
> file, one can do:
>
>  importFrom("pkgA", foo=bar)
>
> Which will allow you to use the symbol 'foo' to refer to pkgA::bar.
> This is exactly what I wanted.
>
> Despite the lack of documentation, this seems an intentional feature.
> Is there a reason not to document it and allow it as part of the
> NAMESPACE feature set?
>
> Best,
>
> + seth

-- 
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] How to change names when importing with a NAMESPACE (was: NAMESPACE Q: does import as exist?)
Prof Brian Ripley