Shows the relationship between calls on the stack. This function
combines the results of sys.calls() and sys.parents() yielding a display
that shows how frames on the call stack are related.
cst()# If all evaluation is eager, you get a single tree
f <- function() g()
g <- function() h()
h <- function() cst()
f()
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. └─global `<fn>`(...)
#> 13. └─pkgdown::build_site(...)
#> 14. └─pkgdown:::build_site_local(...)
#> 15. └─pkgdown::build_reference(...)
#> 16. ├─pkgdown:::unwrap_purrr_error(...)
#> 17. │ └─base::withCallingHandlers(...)
#> 18. └─purrr::map(...)
#> 19. └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 20. ├─purrr:::with_indexed_errors(...)
#> 21. │ └─base::withCallingHandlers(...)
#> 22. ├─purrr:::call_with_cleanup(...)
#> 23. └─pkgdown (local) .f(.x[[i]], ...)
#> 24. ├─base::withCallingHandlers(...)
#> 25. └─pkgdown:::data_reference_topic(...)
#> 26. └─pkgdown:::run_examples(...)
#> 27. └─pkgdown:::highlight_examples(code, topic, env = env)
#> 28. └─downlit::evaluate_and_highlight(...)
#> 29. └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#> 30. ├─base::withRestarts(...)
#> 31. │ └─base (local) withRestartList(expr, restarts)
#> 32. │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
#> 33. │ │ └─base (local) doWithOneRestart(return(expr), restart)
#> 34. │ └─base (local) withRestartList(expr, restarts[-nr])
#> 35. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 36. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 37. ├─evaluate:::with_handlers(...)
#> 38. │ ├─base::eval(call)
#> 39. │ │ └─base::eval(call)
#> 40. │ └─base::withCallingHandlers(...)
#> 41. ├─base::withVisible(eval(expr, envir))
#> 42. └─base::eval(expr, envir)
#> 43. └─base::eval(expr, envir)
#> 44. └─f()
#> 45. └─g()
#> 46. └─h()
#> 47. └─lobstr::cst()
# You get multiple trees with delayed evaluation
try(f())
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. └─global `<fn>`(...)
#> 13. └─pkgdown::build_site(...)
#> 14. └─pkgdown:::build_site_local(...)
#> 15. └─pkgdown::build_reference(...)
#> 16. ├─pkgdown:::unwrap_purrr_error(...)
#> 17. │ └─base::withCallingHandlers(...)
#> 18. └─purrr::map(...)
#> 19. └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 20. ├─purrr:::with_indexed_errors(...)
#> 21. │ └─base::withCallingHandlers(...)
#> 22. ├─purrr:::call_with_cleanup(...)
#> 23. └─pkgdown (local) .f(.x[[i]], ...)
#> 24. ├─base::withCallingHandlers(...)
#> 25. └─pkgdown:::data_reference_topic(...)
#> 26. └─pkgdown:::run_examples(...)
#> 27. └─pkgdown:::highlight_examples(code, topic, env = env)
#> 28. └─downlit::evaluate_and_highlight(...)
#> 29. └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#> 30. ├─base::withRestarts(...)
#> 31. │ └─base (local) withRestartList(expr, restarts)
#> 32. │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
#> 33. │ │ └─base (local) doWithOneRestart(return(expr), restart)
#> 34. │ └─base (local) withRestartList(expr, restarts[-nr])
#> 35. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 36. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 37. ├─evaluate:::with_handlers(...)
#> 38. │ ├─base::eval(call)
#> 39. │ │ └─base::eval(call)
#> 40. │ └─base::withCallingHandlers(...)
#> 41. ├─base::withVisible(eval(expr, envir))
#> 42. └─base::eval(expr, envir)
#> 43. └─base::eval(expr, envir)
#> 44. ├─base::try(f())
#> 45. │ └─base::tryCatch(...)
#> 46. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 47. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 48. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 49. └─f()
#> 50. └─g()
#> 51. └─h()
#> 52. └─lobstr::cst()
# Pay attention to the first element of each subtree: each
# evaluates the outermost call
f <- function(x) g(x)
g <- function(x) h(x)
h <- function(x) x
try(f(cst()))
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. └─global `<fn>`(...)
#> 13. └─pkgdown::build_site(...)
#> 14. └─pkgdown:::build_site_local(...)
#> 15. └─pkgdown::build_reference(...)
#> 16. ├─pkgdown:::unwrap_purrr_error(...)
#> 17. │ └─base::withCallingHandlers(...)
#> 18. └─purrr::map(...)
#> 19. └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 20. ├─purrr:::with_indexed_errors(...)
#> 21. │ └─base::withCallingHandlers(...)
#> 22. ├─purrr:::call_with_cleanup(...)
#> 23. └─pkgdown (local) .f(.x[[i]], ...)
#> 24. ├─base::withCallingHandlers(...)
#> 25. └─pkgdown:::data_reference_topic(...)
#> 26. └─pkgdown:::run_examples(...)
#> 27. └─pkgdown:::highlight_examples(code, topic, env = env)
#> 28. └─downlit::evaluate_and_highlight(...)
#> 29. └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#> 30. ├─base::withRestarts(...)
#> 31. │ └─base (local) withRestartList(expr, restarts)
#> 32. │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
#> 33. │ │ └─base (local) doWithOneRestart(return(expr), restart)
#> 34. │ └─base (local) withRestartList(expr, restarts[-nr])
#> 35. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 36. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 37. ├─evaluate:::with_handlers(...)
#> 38. │ ├─base::eval(call)
#> 39. │ │ └─base::eval(call)
#> 40. │ └─base::withCallingHandlers(...)
#> 41. ├─base::withVisible(eval(expr, envir))
#> 42. └─base::eval(expr, envir)
#> 43. └─base::eval(expr, envir)
#> 44. ├─base::try(f(cst()))
#> 45. │ └─base::tryCatch(...)
#> 46. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 47. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 48. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 49. ├─f(cst())
#> 50. │ └─g(x)
#> 51. │ └─h(x)
#> 52. └─lobstr::cst()
# With a little ingenuity you can use it to see how NSE
# functions work in base R
with(mtcars, {cst(); invisible()})
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. └─global `<fn>`(...)
#> 13. └─pkgdown::build_site(...)
#> 14. └─pkgdown:::build_site_local(...)
#> 15. └─pkgdown::build_reference(...)
#> 16. ├─pkgdown:::unwrap_purrr_error(...)
#> 17. │ └─base::withCallingHandlers(...)
#> 18. └─purrr::map(...)
#> 19. └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 20. ├─purrr:::with_indexed_errors(...)
#> 21. │ └─base::withCallingHandlers(...)
#> 22. ├─purrr:::call_with_cleanup(...)
#> 23. └─pkgdown (local) .f(.x[[i]], ...)
#> 24. ├─base::withCallingHandlers(...)
#> 25. └─pkgdown:::data_reference_topic(...)
#> 26. └─pkgdown:::run_examples(...)
#> 27. └─pkgdown:::highlight_examples(code, topic, env = env)
#> 28. └─downlit::evaluate_and_highlight(...)
#> 29. └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#> 30. ├─base::withRestarts(...)
#> 31. │ └─base (local) withRestartList(expr, restarts)
#> 32. │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
#> 33. │ │ └─base (local) doWithOneRestart(return(expr), restart)
#> 34. │ └─base (local) withRestartList(expr, restarts[-nr])
#> 35. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 36. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 37. ├─evaluate:::with_handlers(...)
#> 38. │ ├─base::eval(call)
#> 39. │ │ └─base::eval(call)
#> 40. │ └─base::withCallingHandlers(...)
#> 41. ├─base::withVisible(eval(expr, envir))
#> 42. └─base::eval(expr, envir)
#> 43. └─base::eval(expr, envir)
#> 44. ├─base::with(...)
#> 45. └─base::with.default(...)
#> 46. └─base::eval(substitute(expr), data, enclos = parent.frame())
#> 47. └─base::eval(substitute(expr), data, enclos = parent.frame())
#> 48. └─lobstr::cst()
invisible(subset(mtcars, {cst(); cyl == 0}))
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. └─global `<fn>`(...)
#> 13. └─pkgdown::build_site(...)
#> 14. └─pkgdown:::build_site_local(...)
#> 15. └─pkgdown::build_reference(...)
#> 16. ├─pkgdown:::unwrap_purrr_error(...)
#> 17. │ └─base::withCallingHandlers(...)
#> 18. └─purrr::map(...)
#> 19. └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 20. ├─purrr:::with_indexed_errors(...)
#> 21. │ └─base::withCallingHandlers(...)
#> 22. ├─purrr:::call_with_cleanup(...)
#> 23. └─pkgdown (local) .f(.x[[i]], ...)
#> 24. ├─base::withCallingHandlers(...)
#> 25. └─pkgdown:::data_reference_topic(...)
#> 26. └─pkgdown:::run_examples(...)
#> 27. └─pkgdown:::highlight_examples(code, topic, env = env)
#> 28. └─downlit::evaluate_and_highlight(...)
#> 29. └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#> 30. ├─base::withRestarts(...)
#> 31. │ └─base (local) withRestartList(expr, restarts)
#> 32. │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
#> 33. │ │ └─base (local) doWithOneRestart(return(expr), restart)
#> 34. │ └─base (local) withRestartList(expr, restarts[-nr])
#> 35. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 36. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 37. ├─evaluate:::with_handlers(...)
#> 38. │ ├─base::eval(call)
#> 39. │ │ └─base::eval(call)
#> 40. │ └─base::withCallingHandlers(...)
#> 41. ├─base::withVisible(eval(expr, envir))
#> 42. └─base::eval(expr, envir)
#> 43. └─base::eval(expr, envir)
#> 44. ├─base::subset(...)
#> 45. └─base::subset.data.frame(...)
#> 46. └─base::eval(e, x, parent.frame())
#> 47. └─base::eval(e, x, parent.frame())
#> 48. └─lobstr::cst()
# You can also get unusual trees by evaluating in frames
# higher up the call stack
f <- function() g()
g <- function() h()
h <- function() eval(quote(cst()), parent.frame(2))
f()
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. └─global `<fn>`(...)
#> 13. └─pkgdown::build_site(...)
#> 14. └─pkgdown:::build_site_local(...)
#> 15. └─pkgdown::build_reference(...)
#> 16. ├─pkgdown:::unwrap_purrr_error(...)
#> 17. │ └─base::withCallingHandlers(...)
#> 18. └─purrr::map(...)
#> 19. └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 20. ├─purrr:::with_indexed_errors(...)
#> 21. │ └─base::withCallingHandlers(...)
#> 22. ├─purrr:::call_with_cleanup(...)
#> 23. └─pkgdown (local) .f(.x[[i]], ...)
#> 24. ├─base::withCallingHandlers(...)
#> 25. └─pkgdown:::data_reference_topic(...)
#> 26. └─pkgdown:::run_examples(...)
#> 27. └─pkgdown:::highlight_examples(code, topic, env = env)
#> 28. └─downlit::evaluate_and_highlight(...)
#> 29. └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#> 30. ├─base::withRestarts(...)
#> 31. │ └─base (local) withRestartList(expr, restarts)
#> 32. │ ├─base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
#> 33. │ │ └─base (local) doWithOneRestart(return(expr), restart)
#> 34. │ └─base (local) withRestartList(expr, restarts[-nr])
#> 35. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 36. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 37. ├─evaluate:::with_handlers(...)
#> 38. │ ├─base::eval(call)
#> 39. │ │ └─base::eval(call)
#> 40. │ └─base::withCallingHandlers(...)
#> 41. ├─base::withVisible(eval(expr, envir))
#> 42. └─base::eval(expr, envir)
#> 43. └─base::eval(expr, envir)
#> 44. └─f()
#> 45. ├─g()
#> 46. │ └─h()
#> 47. │ └─base::eval(quote(cst()), parent.frame(2))
#> 48. │ └─base::eval(quote(cst()), parent.frame(2))
#> 49. └─lobstr::cst()