>>>>> "HenrikB" == Henrik Bengtsson <[EMAIL PROTECTED]>
>>>>>     on Thu, 16 Oct 2008 12:51:40 -0700 writes:

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

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

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

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

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

I don't think it will be faster, but definitely cleaner.
I've implemented (a version of) it for R-devel.

Martin

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to