From murdoch at stats.uwo.ca  Thu Feb 24 16:28:16 2005
From: murdoch at stats.uwo.ca (murdoch@stats.uwo.ca)
Date: Thu Feb 24 16:28:26 2005
Subject: [Rd] bug report for as.function (PR#7702)
Message-ID: <20050224152816.A0D10BA61@slim.kubism.ku.dk>

On Thu, 24 Feb 2005 15:59:13 +0100 (CET), becker@kfs.oeaw.ac.at wrote
:

>Hi,
>
>I got the following message in R:
>Error in as.function.default(pdfs[1]) : invalid body argument for "function"
>Should NEVER happen; please bug.report() [mkCLOSXP]

A simpler version is as follows:

> x1 <- list(function() 1)
> x1
[[1]]
function() 1

> as.function(x1)
Error in as.function.default(x1) : invalid body argument for
"function"
Should NEVER happen; please bug.report() [mkCLOSXP]

The problem is that as.function doesn't know how to handle an object
of mode function as the body of a function.  It expects a function
definition to be a call instead:

> x2 <- as.list(function() function() 1)
> x2
[[1]]
function() 1

> as.function(x2)   # no problem this time
function () 
function() 1
> mode(x1)
[1] "list"
> mode(x1[[1]])
[1] "function"
> mode(x2)
[1] "list"
> mode(x2[[1]])  # notice the difference from x1[[1]]
[1] "call"

These tests were done in 

>platform i386-pc-mingw32             
>arch     i386                        
>os       mingw32                     
>system   i386, mingw32               
>status   Under development (unstable)
>major    2                           
>minor    1.0                         
>year     2005                        
>month    02                          
>day      24                          
>language R    

Could someone else please deal with this?  I have trouble with test
builds right now.

Duncan Murdoch


[Rd] bug report for as.function (PR#7702)
murdoch@stats.uwo.ca