18.7 Calls

  • A call object represents a captured function call.
  • Call objects are a special type of list.
    • The first component specifies the function to call (usually a symbol).
    • The remaining elements are the arguments for that call.
  • Call objects create branches in the AST, because calls can be nested inside other calls.
  • You can identify a call object when printed because it looks just like a function call.
  • Confusingly typeof() and str() print language for call objects, but is.call() returns TRUE:
lobstr::ast(read.table("important.csv", row.names = FALSE))
#> █─read.table 
#> ├─"important.csv" 
#> └─row.names = FALSE
x <- expr(read.table("important.csv", row.names = FALSE))
typeof(x)
#> [1] "language"
is.call(x)
#> [1] TRUE