From simon.urbanek at r-project.org  Mon Oct 27 18:49:25 2008
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Mon, 27 Oct 2008 13:49:25 -0400
Subject: [Rd] Arith ops dropping S4 bit [Was: S4 object does not commute?
	(PR#13209)]
In-Reply-To: <20081027162507.CD7BC283416A@mail.pubhealth.ku.dk>
References: <20081027162507.CD7BC283416A@mail.pubhealth.ku.dk>
Message-ID: <607768E4-A332-4AD9-8F22-F89CA88B5C61@r-project.org>


On Oct 27, 2008, at 12:25 , Robert.McGehee at geodecapital.com wrote:

> Hello all,
> It appears that for the simplest of S4 objects, z+1 does not equal  
> 1+z.
> Presumably this is a bug, as 1+z seems to make a malformed object (at
> least malformed as an input to str).

FWIW the difference is that z+1 has the S4 bit set, 1+z does not. The  
objects are otherwise identical. AFAICS the same behavior is  
reproducible with any binary arithmetic operator (i.e. non-S4 %op% S4  
will produce a result with S4 bit cleared yet valid S4 attributes).

Cheers,
S



>
>> setClass("test", representation("vector"))
> [1] "test"
>> z <- new("test", 1)
>> identical(z+1, 1+z)
> [1] FALSE
>> str(z+1)
> Formal class 'test' [package ".GlobalEnv"] with 1 slots
>  ..@ .Data: num 2
>> str(1+z)
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class
> 'test' Class 'test' Class 'test' Class 'test' Class 'test' Class  
> 'test'
> Class 'test' Class 'test' Error: evaluation nested too deeply:  
> infinite
> recursion / options(expressions=3D)?
>
>> R.version
>               _                          =20
> platform       x86_64-unknown-linux-gnu   =20
> arch           x86_64                     =20
> os             linux-gnu                  =20
> system         x86_64, linux-gnu          =20
> status                                    =20
> major          2                          =20
> minor          8.0                        =20
> year           2008                       =20
> month          10                         =20
> day            20                         =20
> svn rev        46754                      =20
> language       R                          =20
> version.string R version 2.8.0 (2008-10-20)
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



[Rd] Arith ops dropping S4 bit [Was: S4 object does not commute? (PR#13209)]
Simon Urbanek