[R] NAMESPACE vs internal.Rd

Berwin A Turlach berwin at maths.uwa.edu.au
Thu Jul 17 12:36:50 CEST 2008

G'day Christophe,

On Wed, 16 Jul 2008 18:22:49 +0200
cgenolin at u-paris10.fr wrote:

> Thanks for your answer.

My pleasure.

> > I guess writing
> > a regular expression that says "export everything that does not
> > start with a dot but do not export foo and bar" would be not
> > trivial to write (at least not for me).
> The NAMESPACE created by package.skeleton contain a single line :
> exportPattern("^[[:alpha:]]+")
> I guess that it is what you just say...

Not really. :)

The regular expression "^[[:alpha:]]+" matches, as far as I know, all
objects that have one or more alphabetic character at the beginning.

The "Writing R Extensions" manual suggests "the directive


exports all variables that do not start with a period."

As far as I can tell, both these instructions have more or less the
same effect (assuming that there are no objects with non-standard names
in your package; and I am not enough of an R language lawyer to know
what would happen in such a case).

I was commenting on your classification as:

> - some fonction will be "accessible" (regular function)
> - some function will be "hidden" (function starting with .)
> - some function will be "forbiden" (function not in namespace)  

Say, you have "accessible" functions called fubar, rabuf, main and
something.incredible.useful, some hidden functions whose name start
with a . and "forbidden" functions (i.e. not exported) with names foo
and bar.  (Though, as I commented earlier, it is practically impossible
to implement "forbidden" functions, users can always access them if
they want using ":::".)

Both of the directives above would export fubar, rabuf, main,
something.incredible.useful, foo and bar.

So my challenge was to come up with a regular expression for
exportPattern that says "export everything that does not start with a
dot but do not export foo and bar", i.e. a regular expression that
would only export the "accessible" functions.




More information about the R-help mailing list