[Rd] Arithmetic not keeping S4-bit on simple extensions

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Tue 14 Nov 2006 - 17:07:31 GMT

This comes from a posting on R-help where the poster found that str(.) didn't work on

     <its-object> / 1
even though <its-object> / 1 looked like a valid "its" object.

Here is a very short script demonstrating the issue :


setClass("mynum", representation = "numeric") x <- new("mynum", pi)
isS4(x) # TRUE
isS4(x * 1) # FALSE -- but wouldn't it make sense to keep the bit here?

x * 1 # show()s in an ugly way -- just because the S4 bit is missing

I wonder if the behavior of primitive (and other "R-builtin" functions) shouldn't be enhanced such that the S4 bit (that was introduced with R version 2.4.0) is kept in simple operations for objects that have a simple .Data slot [use showClass("mynum") ] and the R-builtin is working on that slot like in the above case.


R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 15 04:41:53 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 14 Nov 2006 - 18:30:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.