Re: [R-pkg-devel] Is there a better way ...?

2021-10-21 Thread Andrew Simmons
Duncan's version is much clearer than my solution, and the only reason I use my version is so that the source reference of the function looks neater, and so that auto-code-indentation won't mess up my source reference either. If none of that made sense, don't worry about it, use Duncan's approach.

Re: [R-pkg-devel] Is there a better way ...?

2021-10-21 Thread Martin Maechler
> Duncan Murdoch > on Thu, 21 Oct 2021 08:09:02 -0400 writes: > I agree with almost everything Deepayan said, but would add one thing: > On 21/10/2021 3:41 a.m., Deepayan Sarkar wrote: > ... >> My suggestion is having a package-specific environment, and Duncan's

Re: [R-pkg-devel] Is there a better way ...?

2021-10-21 Thread Duncan Murdoch
I agree with almost everything Deepayan said, but would add one thing: On 21/10/2021 3:41 a.m., Deepayan Sarkar wrote: ... My suggestion is having a package-specific environment, and Duncan's is to have a function-specific environment. If you only need this for this one function, then that

Re: [R-pkg-devel] Is there a better way ...?

2021-10-21 Thread Deepayan Sarkar
On Thu, Oct 21, 2021 at 12:15 PM Rolf Turner wrote: > > > On Thu, 21 Oct 2021 02:03:41 -0400 > Duncan Murdoch wrote: > > > On 21/10/2021 12:40 a.m., Andrew Simmons wrote: > > > I think the simplest answer is to store the variable in the > > > functions frame. I'm assuming here that the only

Re: [R-pkg-devel] Is there a better way ...?

2021-10-21 Thread Rolf Turner
On Thu, 21 Oct 2021 02:03:41 -0400 Duncan Murdoch wrote: > On 21/10/2021 12:40 a.m., Andrew Simmons wrote: > > I think the simplest answer is to store the variable in the > > functions frame. I'm assuming here that the only plot.foo needs > > access to .fooInfo, if not this can be changed. > >

Re: [R-pkg-devel] Is there a better way ...?

2021-10-21 Thread Duncan Murdoch
On 21/10/2021 12:40 a.m., Andrew Simmons wrote: I think the simplest answer is to store the variable in the functions frame. I'm assuming here that the only plot.foo needs access to .fooInfo, if not this can be changed. plot.foo <- function (...) { .fooInfo } environment(plot.foo) <-

Re: [R-pkg-devel] Is there a better way ...?

2021-10-20 Thread Andrew Simmons
I think the simplest answer is to store the variable in the functions frame. I'm assuming here that the only plot.foo needs access to .fooInfo, if not this can be changed. plot.foo <- function (...) { .fooInfo } environment(plot.foo) <- new.env() evalq({ .fooInfo <- NULL },

Re: [R-pkg-devel] Is there a better way ...?

2021-10-20 Thread Deepayan Sarkar
On Thu, Oct 21, 2021 at 9:59 AM Rolf Turner wrote: > > > I have a plot method (say plot.foo()) that I want to be able to call so > that if argument "add" is set equal to TRUE, then further structure will > be added to the same plot. This is to be used *only* in the context in > which the plot

[R-pkg-devel] Is there a better way ...?

2021-10-20 Thread Rolf Turner
I have a plot method (say plot.foo()) that I want to be able to call so that if argument "add" is set equal to TRUE, then further structure will be added to the same plot. This is to be used *only* in the context in which the plot being added to was created using plot.foo(). [Please don't ask