This vignette describes transformations to R code that preserve the original semantics but make analysis easier by standardizing the syntax for certain tasks.

Inserting return() Statements

Functions return the value of their last evaluated expression. An explicit return() is only required to exit a function early. Using return() at the end of a function is discouraged within the R community because it makes code less concise.

Identifying return values is necessary for code generation and also for data flow analyses. We can rewrite code so that all return values have an explicit return(). Then it's easy to find return values by class.

When the last expression in a function is a literal, symbol, or call, the expression can just be wrapped with a return(). Rewriting is not so straightforward when the last expression is an assignment or control flow.

Assignments return the value being assigned, but

Flattening Control Flow



nick-ulle/rstatic documentation built on Oct. 18, 2019, 4:38 a.m.