From wdun|@p @end|ng |rom t|bco@com  Thu Sep 19 20:19:29 2019
From: wdun|@p @end|ng |rom t|bco@com (William Dunlap)
Date: Thu, 19 Sep 2019 11:19:29 -0700
Subject: [Rd] Should slot<-() alter its first argument?
Message-ID: <CAF8bMcan5u+X72Cy2itSbNr=7ovvW7NsZ_q=CX29SfdeOXpmew@mail.gmail.com>

We noticed that the slot<- function alters its first argument, which goes
against the grain of a functional language.  The similar @<- does not
change its first argument.  Is this intended?  The timeSeries and distr
package depend on this altering.

> setClass("Z", rep=representation(x="character"))
> z <- new("Z", x="orig")
> `@<-`(z, "x", value="newer")
An object of class "Z"
Slot "x":
[1] "newer"

> z
An object of class "Z"
Slot "x":
[1] "orig"

>
> `slot<-`(z, "x", value="newest")
An object of class "Z"
Slot "x":
[1] "newest"

> z
An object of class "Z"
Slot "x":
[1] "newest"

Bill Dunlap
TIBCO Software
wdunlap tibco.com

	[[alternative HTML version deleted]]



[Rd] Should slot<-() alter its first argument?
William Dunlap