From murdoch@stats.uwo.ca  Wed Nov 22 14:24:49 2000
From: murdoch@stats.uwo.ca (Duncan Murdoch)
Date: Wed, 22 Nov 2000 09:24:49 -0500
Subject: [Rd] How do you construct a function from a list?
In-Reply-To: <x2n1esp4kc.fsf@blueberry.kubism.ku.dk>
References: <3a1a7d56.44981237@smtp1.sympatico.ca> <14875.46906.371747.98635@mithrandir.hornik.net> <x2n1esp4kc.fsf@blueberry.kubism.ku.dk>
Message-ID: <3a1bd676.166453340@fisher.stats.uwo.ca>

On 22 Nov 2000 13:35:47 +0100, Peter Dalgaard  wrote in message
<x2n1esp4kc.fsf@blueberry.kubism.ku.dk>:

>He is, but this (do_asfunction in coerce.c) looks wrong:
>
>    if( n == 1 )
>        args =  mkCLOSXP(args, arglist, envir);
>    else
>        args =  mkCLOSXP(args, VECTOR_ELT(arglist, n - 1), envir);
>    UNPROTECT(1);

I just posted a bug report about how
"as.function(as.list(somefunction))" doesn't return the function
properly.  Sometimes it does:

 > options(keep.source = F) 
 > noarg _ function() 1
 > noarg
 function () 
 1
 > as.function(as.list(noarg))
 function () 
 1

So it depends on the type of body whether as.function works properly.

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


[Rd] How do you construct a function from a list?
Duncan Murdoch