Re: [R] How to change the value of a class slot

2005-06-09 Thread Thomas Petzoldt
Ross Boylan wrote: The paper also notes that call-by-value vs call-by-reference, which is the root of the slot update problem, is really orthogonal to the FOOP/COOP distinction. It's easy to imagine FOOP with call-by-reference. R.oo uses references. Yes, it can be found on http://www.maths.l

Re: [R] How to change the value of a class slot

2005-06-09 Thread Duncan Murdoch
On 6/9/2005 3:04 PM, Ross Boylan wrote: On Wed, 2005-06-08 at 09:13 +0200, Uwe Ligges wrote: [extensive deletions. Discussion concerned my desire to have a function change the value of an object in a way that had effects outside of the function, without returning the object.] >>You have to t

Re: [R] How to change the value of a class slot

2005-06-09 Thread Thomas Petzoldt
Ross Boylan wrote: I believe your example assumes that foo is updating the outer a by "cheating" and directly modifying enclosing environments. (I figure it also needs to get the name of its actual argument to do this, which would also involve slightly dirty tricks.) This does seem to be the on

Re: [R] How to change the value of a class slot

2005-06-09 Thread Ross Boylan
On Wed, 2005-06-08 at 09:13 +0200, Uwe Ligges wrote: [extensive deletions. Discussion concerned my desire to have a function change the value of an object in a way that had effects outside of the function, without returning the object.] > >>You have to think about scoping rules and it > >>wil

Re: [R] How to change the value of a class slot

2005-06-09 Thread Ross Boylan
On Wed, 2005-06-08 at 14:15 +0200, Thomas Petzoldt wrote: ... > Hello Ross, > > I see that your question was related to S4, but I just noticed a > solution based on the R.oo package so I thought I would add a solution > based on the proto package too. We had similar problems several times > ago an

Re: [R] How to change the value of a class slot

2005-06-08 Thread Thomas Petzoldt
Ross Boylan wrote: I defined an S4 class with a slot i. Then I wrote a regular function that attempted to increment i. [... details deleted ...] What do I need to do to update slot values? Here are some possibly relevant code fragments setClass("CompletePathMaker", representation(i

Re: [R] How to change the value of a class slot

2005-06-08 Thread Uwe Ligges
Ross Boylan wrote: On Tue, 2005-06-07 at 08:36 +0200, Uwe Ligges wrote: Ross Boylan wrote: On Sat, Jun 04, 2005 at 07:08:56PM +0200, Martin Maechler wrote: Ross> nextPath <- function(pm){ #pm is a CompletePathMaker Ross>[EMAIL PROTECTED] <- [EMAIL PROTECTED](1) Ross> [etc] If

RE: [R] How to change the value of a class slot [INFO]

2005-06-07 Thread Ross Boylan
On Tue, 2005-06-07 at 13:49 -0700, Berton Gunter wrote: > > Second, in my experiments I couldn't get setReplacementMethod to work: > > > > "bumpIndex<-" <- function(pm, value) { > > [EMAIL PROTECTED] <- [EMAIL PROTECTED](value) > > pm > > } > > > > # I get an error without the next function d

Re: [R] How to change the value of a class slot

2005-06-07 Thread Henrik Bengtsson
Berton Gunter wrote: Second, in my experiments I couldn't get setReplacementMethod to work: "bumpIndex<-" <- function(pm, value) { [EMAIL PROTECTED] <- [EMAIL PROTECTED](value) pm } # I get an error without the next function definition bumpIndex <- function(pm) [EMAIL PROTECTED] setReplaceMe

RE: [R] How to change the value of a class slot

2005-06-07 Thread Berton Gunter
> Second, in my experiments I couldn't get setReplacementMethod to work: > > "bumpIndex<-" <- function(pm, value) { > [EMAIL PROTECTED] <- [EMAIL PROTECTED](value) > pm > } > > # I get an error without the next function definition > bumpIndex <- function(pm) [EMAIL PROTECTED] > > setReplaceM

Re: [R] How to change the value of a class slot

2005-06-07 Thread Ross Boylan
On Tue, 2005-06-07 at 08:36 +0200, Uwe Ligges wrote: > Ross Boylan wrote: > > > On Sat, Jun 04, 2005 at 07:08:56PM +0200, Martin Maechler wrote: > > > >>Ross> nextPath <- function(pm){ #pm is a CompletePathMaker > >>Ross>[EMAIL PROTECTED] <- [EMAIL PROTECTED](1) > >>Ross> [etc] >

RE: [R] How to change the value of a class slot

2005-06-07 Thread Ross Boylan
On Mon, 2005-06-06 at 14:15 -0700, Berton Gunter wrote: > I'm puzzled: > > > It looks as if instances of class objects are best thought of as > > immutable once created. > > > > what then is setReplaceMethod() for? assignment operators do the whole object replacement behind the scenes, at least

Re: [R] How to change the value of a class slot

2005-06-06 Thread Uwe Ligges
Ross Boylan wrote: On Sat, Jun 04, 2005 at 07:08:56PM +0200, Martin Maechler wrote: Ross> nextPath <- function(pm){ #pm is a CompletePathMaker Ross>[EMAIL PROTECTED] <- [EMAIL PROTECTED](1) Ross> [etc] If your nextPath function has 'pm' as its last statement it will return the

Re: [R] How to change the value of a class slot

2005-06-06 Thread Ross Boylan
On Sat, Jun 04, 2005 at 07:08:56PM +0200, Martin Maechler wrote: > Ross> nextPath <- function(pm){ #pm is a CompletePathMaker > Ross>[EMAIL PROTECTED] <- [EMAIL PROTECTED](1) > Ross> [etc] > > If your nextPath function has 'pm' as its last statement it > will return the updated

Re: [R] How to change the value of a class slot

2005-06-04 Thread Martin Maechler
> "Ross" == Ross Boylan <[EMAIL PROTECTED]> > on Fri, 03 Jun 2005 17:04:08 -0700 writes: Ross> I defined an S4 class with a slot i. Then I wrote a regular function Ross> that attempted to increment i. Ross> This didn't work, apparently because of the general rule that a