Antoine Fabri
2020-Aug-24 14:51 UTC
[Rd] browser() cannot be called consistently from another environment
Dear R-devel, I have this debugging function that applies side effects, then acts like browser once it's done : meta_browser <- function() { # ... on.exit(eval.parent(quote(browser()))) } I can use it with a function such as fun1 below : fun1 <- function(){ meta_browser() print("hello") print("world") } fun1() will trigger the debugger as expected and we can browse along. If however my function contains a loop (for, while, repeat), I'm not able to debug anymore. fun2 <- function(){ meta_browser() print("hello") print("world") repeat {break} } fun2() will trigger the debugger but then everything will be executed at once. Is this a bug ? Is there another way, maybe more idiomatic, to get the same effect and have it work with fun2() ? Best, Antoine [[alternative HTML version deleted]]