From yzhou@arcturusag.com  Thu Aug  1 22:20:13 2002
From: yzhou@arcturusag.com (Yi-Xiong Zhou)
Date: Thu, 1 Aug 2002 14:20:13 -0700
Subject: update() can not find objects (PR#1861)
Message-ID: <BBAF0DEC119BD41193C100B0D0788DFE1D234C@GENOME>

Could an object carry the information about where it was created? Could that
be on the wish list? 

Yi-Xiong

-----Original Message-----
From: Thomas Lumley [mailto:tlumley@u.washington.edu]
Sent: Thursday, August 01, 2002 2:14 PM
To: Yi-Xiong Zhou
Cc: 'Peter Dalgaard BSA'; r-devel@stat.math.ethz.ch;
R-bugs@biostat.ku.dk
Subject: RE: update() can not find objects (PR#1861)


On Thu, 1 Aug 2002, Yi-Xiong Zhou wrote:

> Thanks Peter. This does work for formula. However, it failed to a function
> call. Here is another test script:
>
> ################# begin test ###############
> fun1 <- function() {
>    x <- matrix(rnorm(500), 20,25)
>    oo <- fun3(x)
>    print("step 1")
>    update(oo)
>    print("first update success.")
>    fun2(oo)
> }
>
> fun2 <- function(gg) {
>    update(gg)
>    print("second update success.")
> }
>
> fun3 <- function(aa) {
>    oo <- list(x=aa, call=match.call())
>    oo
> }
>
> fun1()
> ############### end test ############
>
> The error message is
>
> [1] "step 1"
> [1] "first update success."
> Error in fun3(aa = x) : Object "x" not found

Yes, but this isn't supposed to work, and can't.

In the first place update() is supposed to work on models, not on
arbitrary objects.

In the second place, the object you are returning contains no information
about where it was created, so it's not possible for update to work out
the correct environment.  In this case the correct environment happens to
be parent.frame(2), but there's no reason why this should be true in
general.


When the object is a model with a formula it does carry information about
where it was defined, so update() can look there.  Your first example
should have worked, and the fact that it didn't is a bug (though arguably
just a wishlist bug).  This new example shouldn't work.


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


update() can not find objects (PR#1861)
Yi-Xiong Zhou