[R] Function in default parameter value closing over variables defined later in the enclosing function

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Sat Jan 26 14:39:20 CET 2019


On Thu, 24 Jan 2019 06:53:20 -0800
Jeff Newmiller <jdnewmil using dcn.davis.ca.us> wrote:

> It would be better to also make secret an argument to outside instead
> of a local variable or to give up on supplying the inside function as
> an argument.

This was in a small, mostly self-contained one-off script that tested
different design of experiment approaches with simulated datasets.

Actually, I should move the "secret" variable to the global level,
together with other global settings like the dataset size and noise
level. There it's accessible to both any functions that might be
interested in it and the user who might want to change it, after all.

-- 
Best regards,
Ivan



More information about the R-help mailing list