[R] browser/debug and for loop (PR#1721)

tlumley@u.washington.edu tlumley@u.washington.edu
Sat, 29 Jun 2002 02:07:51 +0200 (MET DST)

On Fri, 28 Jun 2002, Vadim Ogranovich wrote:

> Dear R-Users,
> It seems like once one invokes browser() inside a loop and steps through the
> body using 'n' any subsequent loop will be "intercepted" by debug()
> function. Here is exactly what I mean
> # fresh R session
> # run a loop that has browser() inside the body
> > for (i in seq(5)) { browser(); print(i) }
> for (i in seq(5)) { browser(); print(i) }
> Called from: NULL
> Browse[1]> n
> n
> debug: print(i)
> Browse[1]> Q
> Q
> #  remove browser(), debug() is still there
> > for (i in seq(5)) { print(i) }
> for (i in seq(5)) { print(i) }
> debug: i
> Browse[1]> Q
> Q
> My guess is that when I was stepping through some function got flagged for
> debugging. I tried to undebug "for", but that didn't work.

This is quite interesting.  Note that the label at the start of the
browser session changes from
  Called from: NULL
  debug: i

This indicates that the DEBUG() flag has got set on an environment (the
global environment in this case). It happens only when you do "n" and then
"Q" in the browser.

I think the fix is to SET_DEBUG(rho,0) when responding to "Q" in
main.c:ParseBrowser, but I'm not certain.


r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch