module: Make a Module

Description Usage Arguments Value Examples

View source: R/core.R

Description

Institute a module object inline or from a file. mod::ule() is a useful shorthand for module() when this package is not attached.

Usage

1
2
3
4
5
6
7
8
module(..., parent = parent.frame(), lock = TRUE,
  expose_private = FALSE)

ule(..., parent = parent.frame(), lock = TRUE,
  expose_private = FALSE)

acquire(module, parent = baseenv(), lock = TRUE,
  expose_private = FALSE)

Arguments

...

module expression

parent

the enclosing environment

lock

lock the environment; logical

expose_private

expose the private environment as '..private..'; logical

module

module object, or path to a module file

Value

an environment of class module containing defined objects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# from file
module_path <- system.file("misc", "example_module.R", package = "mod")
example_module <- acquire(module_path)

example_module$e(123)

# inline
my_module <- mod::ule({
    a <- 1
    .a <- 2
    f <- function(){.a}
})

my_module$a
my_module$f

mod documentation built on Aug. 23, 2019, 5:05 p.m.

Related to module in mod...