Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.GSO.4.21.0003210834560.14323-100000@mail.biostat.washington.edu>
Date: 2000-03-21T16:40:14Z
From: Thomas Lumley
Subject: is.null(list()) is FALSE ?
In-Reply-To: <Pine.LNX.4.21.0003211507220.16848-100000@boromir.ci.tuwien.ac.at>

On Tue, 21 Mar 2000, Torsten Hothorn wrote:

> 
> On R-1.0.0, debian GNU/Linux, 
> 
> R> is.null(list())
> FALSE
> 
> conflicts with the help for ?is.null:
> 
> Examples:
> 
>      is.null(list())    # TRUE (not so in S)
>      is.null(integer(0))# F
>      is.null(logical(0))# F
>      as.null(list(a=1,b='c'))
> 
> and, I would like is.null(list()) to be TRUE :-)

My guess is that this dates from old-style pairlists, where list() could
easily be NULL. Now a list is internally a vector, so list() is a vector
of length zero and so is stored as a VECTOR node.

Also, a difficulty with storing list() as NULL is that you can't set
attributes on NULL:
R> a<-NULL
R> attr(a,"foo")<-"bar"
Error: attempt to set an attribute on NULL
R> a<-list()
R> attr(a,"foo")<-"bar"
R> a
list()
attr(,"foo")
[1] "bar"


	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

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