expr captures code without executingeval evaluates the code expressionNote
This chapter focuses on capturing and inspecting the operation. eval will be discussed more in chapters 19 and 20.
ast parses and identifies the parts of an expressionast identify expression data structuresast leavesrlang::is_syntactic_literalast leavesis.name or is.symbolrlang::sym or rlang::symsrlang::as_string or as.characterast branches.typeof and str return “language” for call objects#> [1] 3
#> [1] FALSE
#> [1] "0x1d950654c40"
#> [1] "0x1d94815bff0"
#> [1] "0x1d948b7b9e0"
#> [1] "0x1d950654ce8"
#> [1] "0x1d94815bff0" "0x1d948b7b9e0" "0x1d950654ce8"
#> [1] "<000001D95238AD28>"
#> 10 * 2
#> tracemem[0x000001d95238ad28 -> 0x000001d9545baf90]: eval eval withVisible withCallingHandlers eval eval with_handlers doWithOneRestart withOneRestart withRestartList doWithOneRestart withOneRestart withRestartList withRestarts <Anonymous> evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers with_options <Anonymous> process_file <Anonymous> <Anonymous> execute .main
#> 4 * 2
call2, parse_expr, or expr_textbase::parse (text argument) is equivalent to rlang::parse_exprbase::deparse outputs a vector when spanning linesexpr and purrr::reduce#> # A tibble: 5 × 1
#> x
#> <chr>
#> 1 a
#> 2 b
#> 3 c
#> 4 d
#> 5 e
#> # A tibble: 7 × 1
#> x
#> <chr>
#> 1 a
#> 2 b
#> 3 c
#> 4 d
#> 5 e
#> 6 f
#> 7 g
rlang::missing_arg()... argument is associated with an empty symbolbase::expression and base::parsebase::eval works across te elements, but this is confusing compared to evaluating across a list of expressions