From murdoch.duncan at gmail.com  Thu Oct 22 23:25:20 2015
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Thu, 22 Oct 2015 17:25:20 -0400
Subject: [Rd] Changed behaviour when passing a function?
In-Reply-To: <CAO1zAVb9azyYRR-fu5EKwzv0h9Rhu_tuL6oVtbyA1rW_5hAnFw@mail.gmail.com>
References: <CAO1zAVb9azyYRR-fu5EKwzv0h9Rhu_tuL6oVtbyA1rW_5hAnFw@mail.gmail.com>
Message-ID: <56295440.2080002@gmail.com>

On 22/10/2015 1:59 PM, Joris Meys wrote:
> Hi all,
>
> When teaching this year's class, I was quite amazed that one of my examples
> didn't work any longer. I wanted to illustrate the importance of
> match.fun() with following code:
>
> myfun <- function(x, FUN, ...){
>      FUN(x, ...)
> }
> round <- 2
> myfun(0.85, FUN = round, digits=1)
>
> I expected to see an error, but this code doesn't generate one. It seems as
> if in the current R version match.fun() is added automatically.
>
> I've scrolled through the complete R News section specifying all the
> changes and bug fixes, starting from 3.0.0.  I couldn't find anything on
> that change in behaviour though. Where can I find more information on what
> changed exactly?
>

When you say "current R version", what do you mean?  I see an error:

 > myfun <- function(x, FUN, ...){
+     FUN(x, ...)
+ }
 > round <- 2
 > myfun(0.85, FUN = round, digits=1)
Error in myfun(0.85, FUN = round, digits = 1) (from #2) :
   could not find function "FUN"

I see this in 3.2.2, R-patched and R-devel.

Duncan Murdoch



[Rd] Changed behaviour when passing a function?
Duncan Murdoch