R-alpha: R 0.50.a1 problem

Peter Dalgaard BSA p.dalgaard@kubism.ku.dk
28 Jul 1997 21:24:45 +0200


Kurt Hornik <hornik@ci.tuwien.ac.at> writes:

> R> test2
> function (x) 
> {
>         attr(x, "call") <- sys.call()
>         x
> }
> R> test2(x)
> Error: stack overflow
> ********************************************************
> 
> Using the attr() form results in an endless loop ...

Sounds familiar. The "assignment causes evaluation effect". Hey,
here's an amusing variant:

> fff<-function(){cll<-substitute(ls());print(cll);x<-1;
attr(x,"junk")<-cll;x}
> fff
function () 
{
        cll <- substitute(ls())
        print(cll)
        x <- 1
        attr(x, "junk") <- cll
        x
}
> fff()
ls()
[1] 1
attr(,"junk")
[1] "*tmp*" "cll"   "x"    
> fff
function () 
{
        cll <- substitute(ls())
        print(cll)
        x <- structure(1, junk = c("*tmp*", "cll", "x"))
        attr(x, "junk") <- cll
        x
}
> 

...I know that R is a functional programming language and that
functions can write and modify other functions, but this seems to be
overdoing it a bit, donchathinkso <evil grin>? 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-