func_from_expr

0th

Percentile

Get funcion(s) from a single expression. Usually a single function, but not necessarily.

Get funcion(s) from a single expression. Usually a single function, but not necessarily.

Keywords
internal
Usage
func_from_expr(expr, rfile, env)
Arguments
expr
Expression to evaluate.
rfile
Name of the R file being parsed, to be able to use it in a warning message.
env
Environment to store the parsed objects in.
Details

If the expression has a function token and at least one assignment, then we assume that it is a function definition and evaluate it to get the function name. This is the current algorithm:

  • We evaluate the expression in env.
  • Then we check if there is anything new in env.
  • If there is a single new function, then we assume that the expression is the definition of this function, and use the function's name as expression name.
  • Otherwise (zero or more than one new functions), we assume that the expression is not a function defition and we assign it to the function body (_).

    Othewise we assume it is not a function definition.

Value

A named list of length one. (It is easy to concatenate these lists in the caller, hence the format. A list with a name and an expression is less convenient.)

Aliases
  • func_from_expr
Documentation reproduced from package functionMap, version 1.0.0, License: GPL-2

Community examples

Looks like there are no examples yet.