rlang (version 0.0.0.9000)

call_fn_name: Extract function name of a call

Description

Extract function name of a call

Usage

call_fn_name(call = NULL)

Arguments

call
Can be a call, a formula quoting a call in the right-hand side, or a frame object from which to extract the call expression. If not supplied, the calling frame is used.

Value

A string with the function name, or NULL if the function is anonymous.

See Also

call_fn()

Examples

Run this code
# Extract the function name from quoted calls:
call_fn_name(~foo(bar))
call_fn_name(quote(foo(bar)))

# The calling expression is used as default:
foo <- function(bar) call_fn_name()
foo(bar)

# Namespaced calls are correctly handled:
call_fn_name(~base::matrix(baz))

# Anonymous and subsetted functions return NULL:
call_fn_name(~foo$bar())
call_fn_name(~foo[[bar]]())
call_fn_name(~foo()())

Run the code above in your browser using DataCamp Workspace