Odd outcome of attr with environments (PR#2148)
Thomas Lumley
tlumley@u.washington.edu
Fri, 11 Oct 2002 12:23:14 -0700 (PDT)
On Fri, 11 Oct 2002 j.c.rougier@durham.ac.uk wrote:
> Hi everyone,
>
> I think the following error is slightly odd:
>
> > fred <- new.env()
> > happy <- function() fred
> > happy()
> <environment: 0x8a425b8>
> > attr(happy(), "foo") <- 1:10
> Error: invalid (NULL) left side of assignment
>
It's nothing to do with environments. happy() is not an variable, so you
can't modify it: eg
R> f<-function(){ 42}
R> f()<-1
Error: invalid (NULL) left side of assignment
R> attr(f(),"foo")<-1
Error: invalid (NULL) left side of assignment
R> f()[1]<-1
Error: invalid (NULL) left side of assignment
-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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._