From jmc at research.bell-labs.com  Mon Sep 29 14:25:00 2003
From: jmc at research.bell-labs.com (John Chambers)
Date: Mon Sep 29 19:24:36 2003
Subject: [Rd] does isGeneric work differently in 1.8.0 ?
References: <Pine.GSO.4.21.0309272133020.25794-200000@btr0xe.rz.uni-bayreuth.de>
Message-ID: <3F786AEC.7FB536BA@research.bell-labs.com>

Thomas Stabla wrote:
> 
> Hello,
> 
> the last command (isGeneric) in following R-code (attached) produces
> different output, depending on wheter 1.8.0 alpha or 1.7.1 is used.
> Is that to be expected ?

This is a bug, but one that may be worth understanding.

In order to work properly with namespaces, many of the functions in the
package have changed the default for `where' arguments, from a value
meaning "search in the search list" to one meaning "search in the top
environment of the call to this function".  The isGeneric function seems
to have been overlooked.

If other examples like this arise, let us know. As Peter Dalgaard's
message mentioned, the workaround is to provide an explicit `where'
argument with the environment in which to start the search (typically
.GlobalEnv).  And calls to these functions from within other packages
may need to provide a `where' argument, unless the right default is to
look in the namespace of the package.

John

> 
> Both R Versions were started with option vanilla
> 
> ---------------------------------------------------
> R.1.7.1:
> ---------------------------------------------------
> 
> > version
>          _
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status
> major    1
> minor    7.1
> year     2003
> month    06
> day      16
> language R
> > 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] TRUE
> 
> ---------------------------------------------------
> 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
> > 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
> 
> ---------------------------------------------------
> ---------------------------------------------------
> 
> Greetings,
> Thomas Stabla
> 
>   ------------------------------------------------------------------------
>              Name: code.R
>    code.R    Type: Plain Text (TEXT/PLAIN)
>          Encoding: BASE64
> 
>   ------------------------------------------------------------------------
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel


[Rd] does isGeneric work differently in 1.8.0 ?
John Chambers