How do hidden variables behave in R?
Are there any significant [1] reasons not to export functions with form names. fnname
in R packages?
I understand that the main use of prefix prefixes is to mark a variable as hidden when searched in the environment using functions such as ls
, and to indicate that fields in an object or list should be treated as private as an S4.Data field.
test_env <- new.env(parent = emptyenv())
test_env $ .hidden <- 10
ls(test_env)
# character(0)
ls(test_env, all.names = TRUE)
# ".hidden"
As far as I can tell, the convention is applied at the level of a few useful environment search functions, but not across R in general.
Does a prefix to a variable prefix provide a variable behavior for basic language features such as lexical scope or various object systems, and if so would it make it inappropriate or dangerous to export functions with the dot-prefixed prefix?
Thanks for any help or information you can offer.
Note:
[1] By meaningful, I don't mean stylistic; this library uses special prefixes and suffixes to denote aspects of a function type signature, somewhat similar to a plyr
special naming convention. It would normally be non-semantic to use prefix prefixes, but in this case the meaning has a complex meaning.
source to share
No one has answered this question yet
See similar questions:
or similar: