module: Make a Module

Description Usage Arguments Details Value See Also 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
module(expr, parent = parent.frame(), lock = TRUE)

ule(expr, parent = parent.frame(), lock = TRUE)

acquire(path, parent = baseenv(), lock = TRUE)

Arguments

expr

module expression

parent

the enclosing environment

lock

lock the environment; logical

path

path to a module file

Details

Only use lock = FALSE for runtime debugging. It is otherwise necessary to keep the module locked.

Value

an environment of class module containing defined objects

See Also

use, drop

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

iqis/ntr documentation built on Dec. 7, 2019, 10:20 p.m.