Created
August 15, 2019 17:03
-
-
Save bfatemi/23d24e852eaa532c365c53c2938f56c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rlang) | |
# Symbolic objects and functions are callable: | |
is_callable(quote(foo)) | |
is_callable(base::identity) | |
# node_poke_car() lets you modify calls without any checking: | |
lang <- quote(foo(10)) | |
node_poke_car(lang, current_env()) | |
# Use is_callable() to check an input object is safe to put as CAR: | |
obj <- base::identity | |
if (is_callable(obj)) { | |
lang <- node_poke_car(lang, obj) | |
} else { | |
abort("`obj` must be callable") | |
} | |
eval_bare(lang) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment