[Rd] setReplaceMethod creates 'object' in the userworkspace

Jonathan Fritzemeier clausjonathan.fritzemeier at uni-duesseldorf.de
Fri Jun 23 16:15:30 CEST 2017


Hi,

I recognized that the function 'setReplaceMethod' is creating a
character vector in the user workspace having the name (e.g. "newClass")
of the class used as value. If you can sort out a mistake by myself, I
would like you to file a bug report.

BBFN,
Jonathan

setClass("newClass", representation(value="numeric"))

setMethod(f = "initialize", signature = "newClass",
    definition = function(.Object){
        .Object at value <- 1
    return(.Object)
})

setGeneric(name = "myValue",
        def  = function(object) { standardGeneric("myValue") }
)
setGeneric(name = "myValue<-",
        def  = function(object, value) { standardGeneric("myValue<-") }
)

setMethod("myValue", signature(object = "newClass"),
    function(object) {
        return(object at value)
    }
)

setReplaceMethod("myValue", signature = (object = "newClass"),
    function(object, value) {
        object at value <- value
        return(object)
    }
)

myNewObject <- new("newClass")
print(object)


> print(object)
[1] "newClass"

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0

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=en_US.UTF-8       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    

loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0



More information about the R-devel mailing list