Re: [Rd] Conventions: Use of globals and main functions

2019-08-25 Thread Duncan Murdoch
On 25/08/2019 12:08 a.m., Cyclic Group Z_1 via R-devel wrote: In R scripts (as opposed to packages), even in reproducible scripts, it seems fairly conventional to use the global workspace as a sort of main function, and thus R scripts often populate the global environment with many variables, w

Re: [Rd] Conventions: Use of globals and main functions

2019-08-25 Thread Cyclic Group Z_1 via R-devel
This seems like a nice idiom; I've seen others use    if(!interactive()){        main()    }to a similar effect. Best,CG On Sunday, August 25, 2019, 01:16:06 AM CDT, Gábor Csárdi wrote: This is what I usually put in scripts: if (is.null(sys.calls())) {   main() } This is mostly equiv

Re: [Rd] Conventions: Use of globals and main functions

2019-08-25 Thread Cyclic Group Z_1 via R-devel
This is a fair point; structuring functions into packages is probably ultimately the gold standard for code organization in R. However, lexical scoping in R is really not much different than in other languages, such as Python, in which use of main functions and defining other named functions

Re: [Rd] Conventions: Use of globals and main functions

2019-08-25 Thread Duncan Murdoch
On 25/08/2019 7:09 p.m., Cyclic Group Z_1 wrote: This is a fair point; structuring functions into packages is probably ultimately the gold standard for code organization in R. However, lexical scoping in R is really not much different than in other languages, such as Python, in which use of