From p.dalgaard at biostat.ku.dk  Sat Sep 27 22:10:27 2003
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard BSA)
Date: Sat Sep 27 23:10:28 2003
Subject: [Rd] does isGeneric work differently in 1.8.0 ?
In-Reply-To: <Pine.GSO.4.21.0309272133020.25794-200000@btr0xe.rz.uni-bayreuth.de>
References: <Pine.GSO.4.21.0309272133020.25794-200000@btr0xe.rz.uni-bayreuth.de>
Message-ID: <x2vfreey27.fsf@biostat.ku.dk>

Thomas Stabla <a9265@stud.uni-bayreuth.de> writes:

> R 1.8.1:
> ---------------------------------------------------
> 
> > version
>          _
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status   alpha
> major    1
> minor    8.0
> year     2003
> month    09
> day      25
> language R

Did you get that from rsync? (These have the erroneous "alpha"
designation, the tarballs should say "beta" since Wednesday.) If so,
please consider testing the tarball instead since that allows us to
catch packaging errors too.

> > isGeneric("foo")
> [1] FALSE
> > setClass("woo", representation(foo="character"), prototype = list(foo="text"))
> [1] "woo"
> > if(!isGeneric("foo")) setGeneric("foo", function(object) standardGeneric("foo"))
> [1] "foo"
> > setMethod("foo", "woo", function(object) object@foo)
> [1] "foo"
> > isGeneric("foo")
> [1] FALSE

Hmm. This is still in the current sources. Doesn't quite look
deliberate, but it works to use the explicit

>  isGeneric("foo",environment())
[1] TRUE


What appears to be happening is that we don't get further than this:

> isGeneric
function (f, where = -1, fdef = NULL, getName = FALSE)
{
    if (is.null(fdef)) {
        if (identical(where, -1)) {
            where <- findFunction(f)
            if (length(where) == 0)
                return(FALSE)

findFunction(f) goes looking in the topenv(parent.frame()) but topenv
is using parent.env() and that goes through the *lexical* scope I
believe, so we end up looking for "foo" in the methods namespace.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] does isGeneric work differently in 1.8.0 ?
Peter Dalgaard BSA