Skip to content
Prev 21566 / 63424 Next

.Call question

On Wed, 26 Jul 2006, Rossi, Peter E. wrote:

            
It is dangerous.

If you do

lst1<-list("a","b","c")
lst2<-lst1
element<-"d"
.Call("modlist",lst1, 1, element)

then both lst1 and lst2 will change. The danger is just that you can 
break the call-by-value illusion that R maintains, in two ways. The first 
is that objects that have shared structure can be modified, the 
second is that you can create shared structure without R knowing: if you 
change "element" subsequently then lst1 and lst2 may change.

 	-thomas
Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle