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

From: Thomas Petzoldt <>
Date: Fri 10 Jun 2005 - 05:37:32 EST

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 only
> way to do it in standard R.
> In contrast, I wanted something like
> foo<-function(formalArg){
> formalArg <- new value
> return something else
> }
> so that if I call foo(a), a has the new value after the call.
> Unfortunately for me, that doesn't work. Call-by-value semantics imply
> that it can't.

What about call by reference like this:


arg <- proto(x=1)


   formalArg$x <- formalArg$x + 1.23
   #return something else



[1] 2.23

Best regards

Thomas P. mailing list PLEASE do read the posting guide! Received on Fri Jun 10 05:49:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:28 EST