# 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