flatten_function_body: Flatten a single output's function body

Description Usage Arguments Details Value Examples

Description

When only a single output's code is desired, you can flatten the function body of the nullary output function into the top level of the syntax tree to clean up unnecessary compartmentalization.

Usage

1

Arguments

code

a code block to flatten

name

output to flatten

Details

With more than one output, you run the risk of introducing namespace conflicts that were otherwise handled by compartmentalizing withing functions.

Value

code with last instance of outputs flattened into top level of syntax tree.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
codeblock <- quote({
  a <- 1
  b <- 2
  f <- function() {
    print(a)
    print(b)
  }
})

scriptgloss:::flatten_function_body(codeblock, "f")

dgkf/scriptgloss documentation built on June 8, 2019, 8:43 p.m.