From p.dalgaard@kubism.ku.dk  Mon Jul 28 20:24:45 1997
From: p.dalgaard@kubism.ku.dk (Peter Dalgaard BSA)
Date: 28 Jul 1997 21:24:45 +0200
Subject: R-alpha: R 0.50.a1 problem
In-Reply-To: Kurt Hornik's message of Mon, 28 Jul 1997 15:23:49 +0200
References: <199707281323.PAA18657@aragorn.ci.tuwien.ac.at>
Message-ID: <x2bu3nj7ya.fsf@bush.kubism.ku.dk>

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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


R-alpha: R 0.50.a1 problem
Peter Dalgaard BSA