Re: R-alpha: Puzzles from Luke Tierney

Luke Tierney (luke@stat.umn.edu)
Thu, 30 May 1996 05:25:56 -0500 (CDT)


From: Luke Tierney <luke@stat.umn.edu>
Message-Id: <9605301025.AA03091@nokomis.stat.umn.edu>
Subject: Re: R-alpha: Puzzles from Luke Tierney
To: ihaka@stat.auckland.ac.nz (Ross Ihaka)
Date: Thu, 30 May 1996 05:25:56 -0500 (CDT)
In-Reply-To: <199605300111.NAA04686@stat.auckland.ac.nz> from "Ross Ihaka" at May 30, 96 01:11:26 pm

> -----------------------------------------------------------------------------
> 
>  > > f<-function(y) { y[1]<-3; x<<-y; x[2]<-4;}
>  > > f(c(1,2))
>  > > x
>  > [1] 3 4  # in S it's 3 2
> 
> This the same as yesterday's problem.  There is no local "x" to
> mutate, so the global one gets clobbered.  Since it is easiest :-) we
> will probably make this an error.  This is incompatible behavior, and
> if there is strong sentiment we will do the "make a local copy first"
> thing to get compatibility.
> 

Oops -- this is indeed just an obfuscated version of the example I
sent the other day. What I meant to test was

f<-function(y) { y[1]<-3; x<<-y; y[2]<-4;}
                                 ^

to make sure the second change to y would not affect the global
value. This does indeed work fine. Sorry about the red herring.

> -----------------------------------------------------------------------------
> 
>  > > x<-list(y=NULL)
>  > > x$y<-x
>  > > x
>  > $...
>  > $...
>  > .........
>  > Segmentation fault (core dumped)
>  > 
> 
> This was an oversight in the mutation code.  If you instead try
> 
> x$[[1]]<-x
> 
> You'll find it works.  The $ case is (more) fixed now.
> 
> -----------------------------------------------------------------------------
> 

At the top level it seems OK:

> x<-list(NULL)
> x[[1]]<-x
> x
[[1]]
[[1]]
NULL


But in a function

> f<-function(x) { x[[1]]<-x; x}
> f(list(NULL))
[[1]]
[[1]]
[[1]]
.....
Segmentation fault (core dumped)

THis in in alpha 0.6.

luke

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-