browser() cannot be called consistently from another environment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

browser() cannot be called consistently from another environment

Antoine Fabri
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]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel