[Rd] Bug in new behaviour for all.equal and environments?

Martin Maechler maechler at stat.math.ethz.ch
Tue Sep 23 17:44:09 CEST 2014


>>>>> Duncan Murdoch <murdoch.duncan at gmail.com>
>>>>>     on Sun, 21 Sep 2014 15:57:00 -0400 writes:

    > On 21/09/2014, 1:38 PM, Rui Barradas wrote:
    >> Hello,
    >> 
    >> In R 3.1.1 on Windows 7 it's ok.
    >> 
    >> > all.equal(baseenv(), baseenv()) [1] TRUE >
    >> sessionInfo() R version 3.1.1 (2014-07-10) Platform:
    >> x86_64-w64-mingw32/x64 (64-bit)

    > I'm not sure if that's really "ok", since it returns TRUE
    > for any pair of environments, e.g.

    > all.equal(baseenv(), emptyenv())

    > The current R-devel behaviour is temporary and certain to
    > change.

    > Duncan Murdoch

Indeed.  A bit more than an hour ago, I have committed several
changes to R-devel's behavior in dealing with objects such as 
 
 (rp <- getClass("refClass")@prototype)
 (ner <- new("envRefClass"))

both of which would not even correctly *print* in current R.
They now do in R-devel, also work with str() there, and

  all.equal(baseenv(), baseenv())

and many more cases of all.equal() with environments now work
there as well.

I still expect that creative useRs will be able to construct
cases where the new  all.equal() methods will fail, possibly
even end in an infinite loop (which is caught and leads to an
error).

Please use R-devel  svn rev >= 66668  for such experiments.

Thanking you for testing ...,
Martin Maechler
ETH Zurich



    >> [................]

    >> Rui Barradas
    >> 
    >> Em 21-09-2014 18:06, Kevin Ushey escreveu:
    >>> Hi R-devel,
    >>> 
    >>> The following code:
    >>> 
    >>> all.equal(baseenv(), baseenv())
    >>> 
    >>> gives the error when run in a clean R session with
    >>> latest R-devel (r66650):
    >>> 
    >>> kevin:~$ R --vanilla --slave -e "all.equal(baseenv(),
    >>> baseenv())" Error in all.equal.envRefClass(target[[i]],
    >>> current[[i]], check.attributes = check.attributes, :
    >>> attempt to apply non-function Calls: all.equal
    >>> ... all.equal.list -> all.equal -> all.equal.envRefClass
    >>> Execution halted
    >>> 
    >>> Although I don't know if it's helpful -- it appears that
    >>> packages that include some S4 machinery will effect the
    >>> outcome of this error, e.g.  if we load 'Biobase' first:
    >>> 
    >>> kevin:~$ R --vanilla --slave -e
    >>> "suppressPackageStartupMessages(library(Biobase));
    >>> all.equal(baseenv(), baseenv())" Error in
    >>> target$getClass() : object '.refClassDef' not found
    >>> Calls: all.equal ... all.equal.list -> all.equal ->
    >>> all.equal.envRefClass -> <Anonymous> Execution halted
    >>> 
    >>> We were bumping into an error with this in Rcpp -- we
    >>> used all.equal (through RUnit) to confirm that
    >>> baseenv(), and a function returning the base
    >>> environment, would return TRUE.
    >>> 
    >>> For completeness:
    >>> 
    >>> kevin:~$ R --vanilla --slave -e "sessionInfo()" R Under
    >>> development (unstable) (2014-09-20 r66650) Platform:
    >>> x86_64-apple-darwin13.3.0 (64-bit)
    >>> 
    >>> locale: [1]
    >>> en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
    >>> 
    >>> attached base packages: [1] stats graphics grDevices
    >>> utils datasets methods base
    >>> 
    >>> Thanks, Kevin



More information about the R-devel mailing list