From dmurdoch at pair.com  Wed Dec 24 19:57:44 2003
From: dmurdoch at pair.com (Duncan Murdoch)
Date: Wed Dec 24 19:56:25 2003
Subject: [Rd] Questions and suggestions about namespaces
Message-ID: <2jnjuv0ikq5gk5825pg3kru6ga0mprqqds@4ax.com>

I'm trying to add a namespace to my orientlib package.  It makes use
of S4 methods.

A few questions, and a couple of suggestions:

1.  Is there a way to put version dependency into the NAMESPACE file?
I need to import something from stats in r-devel, but (of course) I
get an error when using the same import directive in r-patched and
earlier versions, because there is no stats package.

2.  Without the namespace, orientlib passes Rcmd CHECK, but when I put
in the namespace in and check in r-patched or r-devel, it fails
running the first example, with the error message

>> x <- eulerzyx(psi=c(0,pi/4,0,0), theta=c(0,0,pi/4,0), phi=c(0,0,0,pi/4))
>Error in getClass(superClass) : "orientation" is not a defined class
>Execution halted

Is there something I need to do to make sure the classes get exported?

3.  Is it necessary to import(methods)?  I'm using S4 methods, but my
functions and methods don't make use of the methods package other than
in their own definition.

4.  When running CHECK in r-patched, I got the following inscrutable
errors:

>* checking S3 generic/method consistency ... WARNING
>Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, character.
>only = TRUE, verbose = FALSE) :
>        package/namespace load failed
>Execution halted
>* checking for replacement functions with final arg not named 'value' ... WARNIN
>G
>Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, character.
>only = TRUE, verbose = FALSE) :
>        package/namespace load failed
>Execution halted
>* checking Rd files ... OK
>* checking for missing documentation entries ... ERROR
>Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, character.
>only = TRUE, verbose = FALSE) :

These were caused because I was trying to export a class name in
working around 2.  The package installed fine with this error, but
when trying to use it I got

>> library(orientlib)
>Error in namespaceExport(ns, exports) : undefined exports: orientation
>Error in library(orientlib) : package/namespace load failed

Suggestion:  the CHECK script should print all errors, not just the
last one, and perhaps should have a check that a namespace can load
properly.

5.  Another suggestion:  even though import(), export() etc. aren't
really functions, it would be nice if "?import" and friends worked to
bring up a man page explaining the syntax and the details.

Duncan Murdoch


[Rd] Questions and suggestions about namespaces
Duncan Murdoch