Skip to content

identical() fails to compare isS4(<S4 instance>) to TRUE

6 messages · Duncan Murdoch, Martin Morgan

#
> isS4(new("A"))
[1] TRUE
 > identical(isS4(new("A")), TRUE)
[1] FALSE

 > sessionInfo()
R Under development (unstable) (2012-10-04 r60876)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=C                 LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
#
On 12-10-04 4:57 PM, Martin Morgan wrote:
I can confirm this in R-devel, but it doesn't happen in R-patched.  In 
R-devel, isS4 is returning a vector marked as LGLSXP, but containing the 
value 16, not the usual 1 for TRUE.

 > .Internal(inspect(isS4(new("A"))))
@4bfbed8 10 LGLSXP g0c1 [] (len=1, tl=0) 16

I'm not going to have time to track this down and fix it.

Duncan Murdoch
#
On 10/04/2012 02:23 PM, Duncan Murdoch wrote:
The bit is set at src/include/Rinternals.h:278

  39103        jmc #define IS_S4_OBJECT(x) ((x)->sxpinfo.gp & S4_OBJECT_MASK)

but it's identical that has changed; it looks as though there are other similar 
operations in that header and probably elsewhere.

Martin

  
    
#
On 12-10-04 5:50 PM, Martin Morgan wrote:
In R-patched, it returned the value 1 for TRUE, so I'm not sure 
identical() has changed.

Duncan Murdoch
#
On 10/04/2012 04:05 PM, Duncan Murdoch wrote:
R version 2.15.1 Patched (2012-09-24 r60798) has

 > isS4
function (object)
.Call("R_isS4Object", object, PACKAGE = "base")

with objects.c:1531

SEXP R_isS4Object(SEXP object)
{
     /* wanted: return isS4(object) ? mkTrue() : mkFalse(); */
     return IS_S4_OBJECT(object) ? mkTrue() : mkFalse(); ;
}

where R-devel has

 > isS4
function (object)  .Primitive("isS4")

with coerce.c:1843

     case 51:		/* isS4 */
	LOGICAL(ans)[0] = IS_S4_OBJECT(CAR(args));
	break;

made in r60395

Martin

  
    
#
On 10/04/2012 05:56 PM, Martin Morgan wrote:
and fixed in r60877, thanks. Martin