From hb at stat.berkeley.edu  Thu Oct 16 21:51:40 2008
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Thu, 16 Oct 2008 12:51:40 -0700
Subject: [Rd] as.list() for function:s
Message-ID: <59d7961d0810161251rc42cb42w3f4dd62bcf82010e@mail.gmail.com>

Hi, a quick comment.  I just notice that as.list() deals with
function:s the old way inside the "default" function, cf.

> as.list.default
function (x, ...)
{
    if (typeof(x) == "list")
        return(x)
    if (is.function(x))
        return(c(formals(x), list(body(x))))
    .Internal(as.vector(x, "list"))
}
<environment: namespace:base>

The following should do the same thing cleaner (and faster?):

as.list.function <- function(x, ...)
{
    c(formals(x), list(body(x)))
}

as.list.default <- function (x, ...)
{
    if (typeof(x) == "list")
        return(x)
    .Internal(as.vector(x, "list"))
}

/Henrik



[Rd] as.list() for function:s
Henrik Bengtsson