The case for globals #55
Replies: 3 comments 11 replies
-
I agree it is good to explore this. If Currently, |
Beta Was this translation helpful? Give feedback.
-
Hello. I'm not sure if it makes a difference, but I use the term "global variable" in the traditional programming sense. For example, f <- function(x) {
a <- 42
g <- function(z) {
a + z
}
g(x)
} Thus, by this definition, a global variable does not have to live in the From my perspective, I don't think there's a need to be able to assign something to the PS. Being able to properly reconstruct all the frames on a parallel worker, with just enough variables to resolve the expression, is really tricky. Things like packages being attached at run-time when the expression is evaluated, complicates it further. |
Beta Was this translation helpful? Give feedback.
-
After further feedback, practicality trumps perceived notions of 'correctness' and my original idea is implemented in 647e65d |
Beta Was this translation helpful? Give feedback.
-
As posed by @HenrikBengtsson in #45.
I was sitting in the SatRdays conference in London this afternoon. And I realised that there are potentially a lot of data scientists working with scripts containing variables and functions, all thrown together in the global environment.
And the situation Henrik pointed out, which I sort of dismissed at the time as a case of 'user error' might be more common than I had anticipated.
As #54 implements
name = value
pairs to be passed via.args
, this frees up...
to be used for another purpose i.e. to pass globals (explicitly assigned to.Globalenv
in the new process).The advantage is that I think this is going to be mostly back compatible with existing code as globals remain on the search path.
An added bonus is that the
...
is on the same level semantically as.expr
in the function, and this also reflects their relative positions in the new process.@wlandau this might allow you in
crew
to mapdata
to.args
andglobals
to...
, potentially saving you a layer?I'm not committed to implementing this, just toying with the idea. Welcome any thoughts / comments.
Beta Was this translation helpful? Give feedback.
All reactions