Re: [Rd] Style question

2014-05-30 Thread Winston Chang
Using `::` does add some overhead - on the order of 5-10 microseconds on my computer. Still, it would take 100,000 calls to add 0.5-1 second of delay. microbenchmark( base::identity(1), identity(1), unit = "us" ) # Unit: microseconds # expr min lq median uqmax nev

Re: [Rd] Style question

2014-05-30 Thread Hervé Pagès
Hi Gabe, On 05/30/2014 11:34 AM, Gabriel Becker wrote: This isn't likely to make much difference in most cases, but calling a function via :: can incur up to about twice the overhead on average compared to calling an imported function > fun1 function () file_ext("text.txt") > fun2 function (

Re: [Rd] Style question

2014-05-30 Thread Gábor Csárdi
On Fri, May 30, 2014 at 9:17 PM, Gábor Csárdi wrote: > On Fri, May 30, 2014 at 9:08 PM, Hadley Wickham > wrote: > >> > Finally, now that the use of a NAMESPACE became mandatory (well, this >> > happened a few years ago), advocating systematic use of foo::whatever() >> > without explicitly impo

Re: [Rd] Style question

2014-05-30 Thread Gábor Csárdi
On Fri, May 30, 2014 at 9:08 PM, Hadley Wickham wrote: > > Finally, now that the use of a NAMESPACE became mandatory (well, this > > happened a few years ago), advocating systematic use of foo::whatever() > > without explicitly importing the function sounds a little bit like an > > heroic act of

Re: [Rd] Style question

2014-05-30 Thread Hadley Wickham
> Finally, now that the use of a NAMESPACE became mandatory (well, this > happened a few years ago), advocating systematic use of foo::whatever() > without explicitly importing the function sounds a little bit like an > heroic act of resistance ;-) I don't think that's at all true - for most other

Re: [Rd] Style question

2014-05-30 Thread Hervé Pagès
On 05/30/2014 10:00 AM, Hadley Wickham wrote: There is at least one subtle consequence to keep in mind when doing this. Of course, whatever choice you make, if the whatever() function moves to a different package, this breaks your package. However, if you explicitly import the function, your pack

Re: [Rd] Style question

2014-05-30 Thread Gábor Csárdi
On Fri, May 30, 2014 at 6:55 PM, Hervé Pagès wrote: [...] > There is at least one subtle consequence to keep in mind when doing > this. Of course, whatever choice you make, if the whatever() function > moves to a different package, this breaks your package. > However, if you explicitly import t

Re: [Rd] Style question

2014-05-30 Thread Gabriel Becker
This isn't likely to make much difference in most cases, but calling a function via :: can incur up to about twice the overhead on average compared to calling an imported function > fun1 function () file_ext("text.txt") > fun2 function () tools::file_ext("text.txt") > microbenchmark(fun1(), time

Re: [Rd] Style question

2014-05-30 Thread Hadley Wickham
> There is at least one subtle consequence to keep in mind when doing > this. Of course, whatever choice you make, if the whatever() function > moves to a different package, this breaks your package. > However, if you explicitly import the function, your package will > break at load-time (which is

Re: [Rd] Style question

2014-05-30 Thread Hervé Pagès
Hi Hadley, On 05/30/2014 07:06 AM, Hadley Wickham wrote: Even more important than choosing between whatever(...) or foo::whatever(...), you should import that function from the foo package by putting importFrom(foo, whatever) or import(foo) in your NAMESPACE file. The 1st form also ki

Re: [Rd] Style question

2014-05-30 Thread Hadley Wickham
> Even more important than choosing between whatever(...) > or foo::whatever(...), you should import that function > from the foo package by putting > > importFrom(foo, whatever) > > or > > import(foo) > > in your NAMESPACE file. > > The 1st form also kind of document what function comes from w

Re: [Rd] Style question

2014-05-28 Thread Hervé Pagès
Hi Ronald, On 05/28/2014 01:46 PM, Ronald Barry wrote: Greetings, When using a 'foreign' function (from another package, say function 'whatever' from package 'foo'), you can of course just require the package and then just have whatever(...) in your code. However, I would like to use the