From dj at research.bell-labs.com  Sat Oct 11 22:55:13 2003
From: dj at research.bell-labs.com (David James)
Date: Sat Oct 11 22:55:17 2003
Subject: [Rd] Problem in 'methods' package (PR#4525)
In-Reply-To: <3F87D1AC.875FD6AD@statistik.uni-dortmund.de>;
	from ligges@statistik.uni-dortmund.de on Sat, Oct 11, 2003 at
	11:47:24AM +0200
References: <200310110620.h9B6Km0P006241@pubhealth.ku.dk>
	<3F87D1AC.875FD6AD@statistik.uni-dortmund.de>
Message-ID: <20031011165513.A11349@jessie.research.bell-labs.com>

Hello,

It seems to me that Fernando may be right.  The problem seems to be
in R 1.8.0 when defining generics with explicit valueClass.  E.g., 

R-1.7.1:

   > setGeneric("foo", function(x) standardGeneric("foo"), valueClass="numeric")
   > setMethod("foo", "numeric", function(x) x )
   > foo(pi)
   [1] 3.141593

R-devel (1.9.0):  (I don't have 1.8.0 handy at this moment).

   > setGeneric("foo", function(x) standardGeneric("foo"), valueClass="numeric")
   > setMethod("foo", "numeric", function(x) x )
   > foo(pi)
   Error in foo(pi) : couldn't find function ".valueClassTest"

whether the problem is in the methods package or the namespace code,
I cannot say.

--
David

Uwe Ligges wrote:
> feferraz@linux.ime.usp.br wrote:
> > 
> > Full_Name: Fernando Henrique Ferraz Pereira da Rosa
> > Version: 1.8.0
> > OS: Linux 2.4.21
> > Submission from: (NULL) (200.206.211.169)
> > 
> >      After installing R 1.8.0, the R DBI interface stopped working. I tracked it
> > down as a problem in the 'methods' package, that comes in the default
> > installation.
> >      Somehow the function '.valueClassTest' which is defined on package
> > 'methods', is not being defined.
> 
> It is. See below.
> 
> >      To ilustrate how this breaks DBI, try this in a 1.8.0 R install (with DBI
> > installed):
> > 
> >       > library(DBI)
> >       > con <- dbConnect(dbDriver("MySQL"), dbname = "test")
> > Error in dbConnect(dbDriver("MySQL"), dbname = "test") :
> >         couldn't find function ".valueClassTest"
> > 
> >       A dirty fix would be defining it by hand (from
> > src/library/methods/R/RMethodUtils.R) :
> > 
> >    .valueClassTest <- function(object, classes, fname) {
> >         (...)
> >     }
> > 
> >        (Which works), but ideally it'd be nice determning why the function is
> > not being defined on the first place.
> 
> Package "methods" has a namespace from which .valueClassTest() is not
> exported, but it's in there, try:
>   methods:::.valueClassTest
> 
> I think .valueClassTest() is not intended to be called by the user, so
> the bug seems to be in package DBI rather than in R, and the maintainer
> of DBI (David A. James <dj@bell-labs.com>, in CC) will certainly fix it.
> 
> Uwe Ligges

-- 
David A. James
Statistics Research, Room 2C-253            Phone:  (908) 582-3082       
Bell Labs, Lucent Technologies              Fax:    (908) 582-3340
Murray Hill, NJ 09794-0636


[Rd] Problem in 'methods' package (PR#4525)
David James