>If I'm not mistaken, this works as documented. ... Thanks for the response.
The behavior with <return> is as documented -- hence my earlier "enhancement" request. The behavior with <a comment> is contrary to the documentation, hence this as a "bug" report. On the second point -- help(browser) says: Anything else entered at the browser prompt is interpreted as an R expression to be evaluated in the calling environment: ... whereas the actual behavior is to interpret a comment as equivalent to "c", and to exit the browser. On the first point -- I would like to argue that the behavior of return (and comments) should be changed, at least as a user option. Here is a typical piece of code from a function; note the use of comments and blank lines to improve readability: # If statistic isn't a function or name of function or expression, # store it as an expression to pass to fit.func. substitute.stat <- substitute(statistic) if(!is.element(mode(substitute.stat), c("name", "function"))) statistic <- substitute.stat # Get name of data. data.name <- substitute(data) if(!is.name(data.name)) data.name <- "data" is.df.data <- is.data.frame(data) # How many observations, or subjects if sampling by subject? n <- nObservations <- numRows(data) # n will change later if by subject # Save group or subject arguments? if(is.null(save.subject)) save.subject <- (n <= 10000) if(is.null(save.group)) save.group <- (n <= 10000) If I now stick a browser() in that function, and throw a line at a time from the source file to R, it exits whenever I throw a blank line or comment. I try to remember to skip the blank lines and comments, but I sometimes forget, and get very annoyed when I have to start over. I could use "c" in some contexts, but not others: * I often want to evaluate code that is not part of the defined function. * I sometimes change objects and want to go evaluate some lines that were previously evaluated. In the enhancement request I requested an option to turn off the current behavior of return. I personally would just change the default behavior, and have both blank lines and comments do nothing. This is simpler, and people can always use c to quit the browser. This behavior of browser() is the most annoying thing I've found about using R. As I anticipate using R a lot in the future, I would appreciate very much if it is changed. I spent a fair amount of time trying to see if I could change it myself, but gave up. Tim Hesterberg Andy Liaw wrote: >If I'm not mistaken, this works as documented. As an example (typed >directly into the Rgui console on WinXP): > >R> f <- function() { >+ browser() >+ cat("I'm here!\n") >+ cat("I'm still here!\n") >+ } >R> f() >Called from: f() >Browse[1]> ## where to? >I'm here! >I'm still here! > >which I think is what you saw. However: > >R> f() >Called from: f() >Browse[1]> n >debug: cat("I'm here!\n") >Browse[1]> ## >I'm here! >debug: cat("I'm still here!\n") >Browse[1]> >I'm still here! > >From ?browser: > >c >(or just return) exit the browser and continue execution at the next >statement. >cont >synonym for c. >n >enter the step-through debugger. This changes the meaning of c: see the >documentation for debug. > >My interpretation of this is that, if the first thing typed (or pasted) in >is something like a null statement (e.g., return, empty line, or comment), >it's the same as 'c', but if the null statement follows 'n', then it behaves >differently. > > _ >platform i386-pc-mingw32 >arch i386 >os mingw32 >system i386, mingw32 >status >major 2 >minor 3.1 >year 2006 >month 06 >day 01 >svn rev 38247 >language R >version.string Version 2.3.1 (2006-06-01) > > >Andy > > >From: [EMAIL PROTECTED] >> >> I'm trying to step through some code using browser(), >> executing one line at a time. >> Unfortunately, whenever I execute a comment line, the browser exits. >> >> I previously reported a similar problem with blank lines. >> >> These problems are a strong incentive to write poor code >> -- uncommented code with no blank lines to improve >> readability -- so that I can use browser() without it exiting >> at inconvenient times. >> >> Additional detail: >> (1) I'm running R inside emacs, with R in one buffer and a >> file containing code in another, using a macro to copy and >> paste a line at a time from the file to the R buffer. >> (2) The browser() call is inside a function. >> Right now the lines I'm sending to the browser are not part >> of the function, though usually they are. >> >> >> --please do not edit the information below-- >> >> Version: >> platform = i386-pc-mingw32 >> arch = i386 >> os = mingw32 >> system = i386, mingw32 >> status = >> major = 2 >> minor = 3.1 >> year = 2006 >> month = 06 >> day = 01 >> svn rev = 38247 >> language = R >> version.string = Version 2.3.1 (2006-06-01) >> >> Windows XP Professional (build 2600) Service Pack 2.0 >> >> Locale: >> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United >> States.1252;LC_MONETARY=English_United >> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 >> >> Search Path: >> .GlobalEnv, package:methods, package:stats, >> package:graphics, package:grDevices, package:utils, >> package:datasets, Autoloads, package:base >> >> ______________________________________________ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> > > >------------------------------------------------------------------------------ >Notice: This e-mail message, together with any attachments...{{dropped}} ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel