Re: [Rd] improved error message when existing implicit S4 generic is not imported?

2012-03-01 Thread Hervé Pagès

Hi,

On 02/27/2012 12:22 AM, Prof Brian Ripley wrote:
...

(Re another message: stats4 *is* methodsGenerics for base packages.)


Why isn't it called base4 if it's for base packages?

Thanks,
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] improved error message when existing implicit S4 generic is not imported?

2012-02-27 Thread Prof Brian Ripley
I think the message is accurate [*]: you do however need to have a clear 
understanding of the scoping issues involved, and no message is going to 
give you that.


In short, implicit generics are converted (or not) into explicit 
functions to be dumped during the dump-for-lazy-loading phase of R CMD 
INSTALL: loading the namespace finds whatever function of that name is 
in scope at that time, and once there are multiple functions of the same 
name around, different ones may be in scope at different times.


To take one recent example from CRAN:


library(VGAM) # fine, as VGAM loads stats4 via Depends:


and in another session


loadNamespace('VGAM')
Error: Functions for exporting methods must have been made generic, 
explicitly or implicitly; not true when loading ‘VGAM’ for ‘AIC’, ‘logLik’


since the visible function AIC() when the namespace alone is loaded is 
the one in stats, not the one in stats4 which was visible when the 
package was dumped for lazy-loading.


I have little idea how one could express all the possibilities for user 
error in an error message like this: as the CRAN maintainers have found, 
some package authors cannot comprehend even several-paragraph 
explanations tailored to their specific errors.  But I might have 
written something like:


The function 'plot' found when exporting methods from the namespace 
'pkgB' is not an S4 generic.


Hopefully such experiences will encourage people to write NAMESPACE 
files more carefully, and also to import generics from e.g. stats4 which 
was long ago provided for that purpose.  (Re another message: stats4 
*is* methodsGenerics for base packages.)



[*]  at least now that it tells you which namespace is involved, unlike 
the original version 




On 26/02/2012 06:39, Martin Morgan wrote:

pkgA's NAMESPACE has

importFrom(graphics, plot)
exportClasses(A)
exportMethods(plot)

R/foo.R has

setClass(A)
setMethod(plot, A, function(x, y, ...) {})

During R CMD INSTALL pkgA_1.0.tar.gz we are told

** preparing package for lazy loading
Creating a generic function for 'plot' from package 'graphics' in
package 'pkgA'
** help
No man pages found in package ‘pkgA’
*** installing help indices
** building package indices
** testing if installed package can be loaded

* DONE (pkgA)

pkgB has in its DESCRIPTION

Depends; pkgA

with NAMESPACE

importFrom(graphics, plot)
exportClasses(B)
exportMethods(plot)

R/bar.R has

setClass(B)
setMethod(plot, B, function(x, y, ...) {})

During R CMD INSTALL pkgB_1.0.tar.gz we are told

** preparing package for lazy loading
** help

i.e., no implicit generic created (because graphics::plot already has an
implicit generic created, when the pkgA dependency was attached?). and also

** testing if installed package can be loaded
Error : Functions for exporting methods must have been made generic,
explicitly or implicitly; not true when loading 'pkgB' for 'plot'
Error: loading failed
Execution halted
ERROR: loading failed

which doesn't seem accurate, rather 'pkgB' does not import S4 implicit
generic for 'plot' created by 'pkgA'

  sessionInfo()
R Under development (unstable) (2012-02-25 r58492)
Platform: x86_64-unknown-linux-gnu (64-bit)

Martin



--
Brian D. Ripley,  rip...@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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] improved error message when existing implicit S4 generic is not imported?

2012-02-25 Thread Martin Morgan

pkgA's NAMESPACE has

  importFrom(graphics, plot)
  exportClasses(A)
  exportMethods(plot)

R/foo.R has

  setClass(A)
  setMethod(plot, A, function(x, y, ...) {})

During R CMD INSTALL pkgA_1.0.tar.gz we are told

** preparing package for lazy loading
Creating a generic function for 'plot' from package 'graphics' in 
package 'pkgA'

** help
No man pages found in package  ‘pkgA’
*** installing help indices
** building package indices
** testing if installed package can be loaded

* DONE (pkgA)

pkgB has in its DESCRIPTION

  Depends; pkgA

with NAMESPACE

  importFrom(graphics, plot)
  exportClasses(B)
  exportMethods(plot)

R/bar.R has

  setClass(B)
  setMethod(plot, B, function(x, y, ...) {})

During R CMD INSTALL pkgB_1.0.tar.gz we are told

** preparing package for lazy loading
** help

i.e., no implicit generic created (because graphics::plot already has an 
implicit generic created, when the pkgA dependency was attached?). and also


** testing if installed package can be loaded
Error : Functions for exporting methods must have been made generic, 
explicitly or implicitly; not true when loading 'pkgB' for 'plot'

Error: loading failed
Execution halted
ERROR: loading failed

which doesn't seem accurate, rather 'pkgB' does not import S4 implicit 
generic for 'plot' created by 'pkgA'


 sessionInfo()
R Under development (unstable) (2012-02-25 r58492)
Platform: x86_64-unknown-linux-gnu (64-bit)

Martin
--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel