search for: collectstr

Displaying 3 results from an estimated 3 matches for "collectstr".

Did you mean: collector
2019 Aug 26
2
Conventions: Use of globals and main functions
...and (b) if you do not find it make a new entry for it in .GlobalEnv. Should R deprecate the second part of that and give an error if 'name' is not already present in the environment stack? This would catch misspelling errors in functions that collect results from recursive calls. E.g., collectStrings <- function(list) { strings <- character() # to be populated by .collect .collect <- function(x) { if (is.list(x)) { lapply(x, .collect) } else if (is.character(x)) { strings <<- c(strings, x) } misspelledStrings &lt...
2019 Aug 26
0
Conventions: Use of globals and main functions
...results from recursive > calls.? E.g., I like that suggestion. Package tests have been complaining about packages writing to .GlobalEnv for a while now, so there probably aren't many instances of b) in CRAN packages; that change might be relatively painless. Duncan Murdoch > > collectStrings <- function(list) { > ? ? strings <- character() # to be populated by .collect > ? ? .collect <- function(x) { > ? ? ? ? if (is.list(x)) { > ? ? ? ? ? ? lapply(x, .collect) > ? ? ? ? } else if (is.character(x)) { > ? ? ? ? ? ? strings <<- c(strings, x) &gt...
2019 Aug 25
2
Conventions: Use of globals and main functions
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 outside of main are encouraged. For example, in Scheme, from which R derives its scoping rules, the