From tlumley@u.washington.edu  Fri Oct 11 20:23:14 2002
From: tlumley@u.washington.edu (Thomas Lumley)
Date: Fri, 11 Oct 2002 12:23:14 -0700 (PDT)
Subject: Odd outcome of attr with environments (PR#2148)
In-Reply-To: <200210111838.UAA29229@pubhealth.ku.dk>
Message-ID: <Pine.A41.4.44.0210111220500.64826-100000@homer30.u.washington.edu>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Odd outcome of attr with environments (PR#2148)
Thomas Lumley