The definition operator is typically used in DSL packages like ggvis and data.table. It is exported in rlang as a alias to ~. This makes it a quoting operator that can be shared between packages for computing on the language. Since it effectively creates formulas, it is immediately compatible with rlang's formulas and interpolation features.

":="()

is_definition(x)

new_definition(lhs, rhs, env = caller_env())

Arguments

x

An object to test.

lhs, rhs

Expressions for the LHS and RHS of the definition.

env

The evaluation environment bundled with the definition.

Examples

# This is useful to provide an alternative way of specifying # arguments in DSLs: fn <- function(...) ..1 f <- fn(arg := foo(bar) + baz) is_formula(f)
#> [1] FALSE
#> arg
#> foo(bar) + baz
# A predicate is provided to distinguish formulas from the # colon-equals operator: is_definition(a := b)
#> [1] TRUE
is_definition(a ~ b)
#> [1] FALSE