[Rd] does isGeneric work differently in 1.8.0 ?

John Chambers jmc at research.bell-labs.com
Mon Sep 29 14:25:00 MEST 2003


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 at 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 at foo)
> [1] "foo"
> > isGeneric("foo")
> [1] FALSE
> 
> ---------------------------------------------------
> ---------------------------------------------------
> 
> Greetings,
> Thomas Stabla
> 
>   ------------------------------------------------------------------------
>              Name: code.R
>    code.R    Type: Plain Text (TEXT/PLAIN)
>          Encoding: BASE64
> 
>   ------------------------------------------------------------------------
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list