Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.A41.4.33.0103230324210.16764-100000@homer34.u.washington.edu>
Date: 2001-03-23T11:26:13Z
From: Thomas Lumley
Subject: Call by reference: Was: Object orientation?
In-Reply-To: <x2r8zqchbw.fsf@blueberry.kubism.ku.dk>

On 22 Mar 2001, Peter Dalgaard BSA wrote:

> "Henrik Bengtsson" <henrikb at braju.com> writes:
>
> > To reply to Yves Gauvreau question (Jan 24, 2001) about how to set values
> > within function, it is possible to do without without using the "<<-"
> > assignment operator or other nasty tricks. I had the same problem and I did
> > a nasty workaround two weeks ago implementing the functionality of reference
> > variables, but today I "ran into" the [R] help page for ".Alias". With
> > .Alias one can immitate call by reference! Here is an example that shows how
> > it works:
> .....
> > set <- function(object, value) {
> >   this <- .Alias(object);
> >   this$value <- value;
> >   return (invisible());
> > }
>
> It may work, but I wouldn't think it is documented to do so and could
> easily get blown away by an internal change (and *I'm* not going to put
> checks in to ensure that it keeps working)!


Some of us talked about putting
  Usage: this function should not be used
in the .Alias help page. It doesn't seem to have happened, but you get the
idea.

	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._