Ah,? looks like this was already reported and discussed here a couple of years ago: https://stat.ethz.ch/pipermail/r-devel/2019-September/078478.html Had no idea that "core of Bioconductor once took advantage of this feature", seems that I've been fooled all these years ;-) Sounds like this would deserve a big warning in ?`slot<-` Thanks, H.
On 22/03/2022 22:17, Herv? Pag?s wrote:
Hi,
I just found out that `slot<-` performs an in-place modification of
the object:
? setClass("A", slots=c(stuff="ANY"))
? x <- new("A", stuff=11:14)
? y <- `slot<-`(x, "stuff", value=99)
Then:
? y
? # An object of class "A"
? # Slot "stuff":
? # [1] 99
? x
? # An object of class "A"
? # Slot "stuff":
? # [1] 99
That doesn't seem right!
Is this violation of the standard pass-by-value semantic somehow
intended here because most of the time people are expected to do
'slot(x, "stuff") <- 99' instead, in which case the violation cannot
be observed so does not matter? I didn't find anything in the man page
about this.
I see this behavior with R 4.1.3 and current R devel.
Thanks,
H.
Herv? Pag?s Bioconductor Core Team hpages.on.github at gmail.com