[Rd] accessing "hidden" functions
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Mar 28 09:00:16 CEST 2007
On Wed, 28 Mar 2007, Benilton Carvalho wrote:
> Hi,
>
> (I tried looking for it, but I don't think it was discussed before...
> or maybe I didn't use the correct keywords).
>
> I have a package (say, pkg1), which uses NAMESPACE. This package
> contains a bunch of functions the are used internally, therefore
> they're not exported (say, internalFunc1).
>
> Even though internalFunc1 is not exported, I can access it externally
> using pkg1:::internalFunc1 (yes, I do understand this is not supposed
> to be done).
>
> Okay... now I have a second internal function, which starts with a
> dot (eg, ".internalFunc2").
>
> Is there a way of accessing it without exporting it (or exposing it
> by removing the "dot")? ie, something like pkg1:::.internalFunc2 ?
Yes. Starting a name with a dot is merely a convention, and almost
everything (including the ::: operator) treats all names the same.
You will see lots of examples in the tools package used by R CMD check.
--
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
More information about the R-devel
mailing list